@charset "UTF-8";

:root {
  color-scheme: light;
  --ink: #16233b;
  --muted: #6d788c;
  --line: #dce3ed;
  --paper: #ffffff;
  --stage: #e9edf3;
  --blue: #2457cc;
  --blue-dark: #173c91;
  --accent: #2457cc;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Pretendard, "Noto Sans KR", "Apple SD Gothic Neo", Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  min-width: 320px;
  min-height: 100%;
  margin: 0;
}

body {
  overflow-x: hidden;
  background: #f6f8fb;
  color: var(--ink);
}

button,
select,
input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 50%;
  padding: 10px 16px;
  border-radius: 10px;
  background: var(--ink);
  color: #fff;
  text-decoration: none;
  transform: translate(-50%, -180%);
}

.skip-link:focus { transform: translate(-50%, 0); }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

.app-shell { min-height: 100vh; }

.edition-screen {
  display: grid;
  min-height: 100vh;
  align-content: center;
  padding: clamp(32px, 6vw, 72px) clamp(18px, 5vw, 64px);
  background:
    radial-gradient(circle at 8% 4%, rgba(36, 87, 204, .09), transparent 34%),
    radial-gradient(circle at 92% 92%, rgba(255, 143, 71, .09), transparent 30%),
    #f8fafc;
}

.edition-header {
  width: min(1120px, 100%);
  margin: 0 auto 34px;
  text-align: center;
}

.brand-logo {
  width: min(310px, 64vw);
  height: 58px;
  object-fit: contain;
}

.edition-kicker {
  margin: 18px 0 8px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .13em;
}

.edition-header h1 {
  margin: 0;
  font-size: clamp(34px, 4vw, 54px);
  letter-spacing: -.055em;
}

.edition-header > p:last-child {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.edition-grid {
  display: grid;
  width: min(1120px, 100%);
  margin: 0 auto;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
}

.edition-screen.is-scoped .edition-grid {
  width: min(430px, 100%);
  grid-template-columns: minmax(280px, 430px);
  justify-content: center;
}

.edition-card {
  --card-accent: #5acb60;
  position: relative;
  display: grid;
  min-height: 280px;
  padding: 30px;
  overflow: hidden;
  border: 1px solid #dfe5ee;
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 18px 42px rgba(32, 48, 78, .08);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
}

.edition-card::after {
  position: absolute;
  right: -52px;
  bottom: -58px;
  width: 168px;
  height: 168px;
  border: 28px solid color-mix(in srgb, var(--card-accent) 18%, transparent);
  border-radius: 50%;
  content: "";
}

.edition-card:hover,
.edition-card:focus-visible {
  border-color: color-mix(in srgb, var(--card-accent) 55%, #dfe5ee);
  outline: none;
  box-shadow: 0 24px 54px color-mix(in srgb, var(--card-accent) 18%, rgba(32, 48, 78, .1));
  transform: translateY(-6px);
}

.edition-card--kids { --card-accent: #ff8f47; }
.edition-card--junior { --card-accent: #3c35bd; }
.edition-card--teen { --card-accent: #dc4f89; }

.edition-number {
  display: grid;
  width: 44px;
  height: 44px;
  margin-bottom: 36px;
  place-items: center;
  border-radius: 50%;
  background: color-mix(in srgb, var(--card-accent) 12%, #fff);
  color: var(--card-accent);
  font-size: 12px;
  font-weight: 950;
}

.edition-name {
  align-self: end;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 800;
  letter-spacing: -.035em;
}

.edition-name-ko {
  margin-top: 7px;
  color: var(--card-accent);
  font-size: 15px;
  font-weight: 900;
}

.edition-meta {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}

.edition-note {
  margin: 24px auto 0;
  color: #8a94a5;
  font-size: 12px;
  text-align: center;
}

.viewer-screen {
  display: grid;
  width: 100%;
  height: 100vh;
  min-width: 0;
  min-height: 560px;
  overflow: hidden;
  grid-template-rows: auto minmax(0, 1fr) auto;
  background: var(--stage);
}

.viewer-header {
  position: relative;
  z-index: 20;
  display: flex;
  min-width: 0;
  min-height: 70px;
  align-items: center;
  gap: 16px;
  padding: 10px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .97);
  box-shadow: 0 2px 12px rgba(23, 35, 58, .04);
}

.icon-button,
.tool-button {
  display: inline-grid;
  width: 42px;
  height: 42px;
  padding: 0;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 12px;
  background: transparent;
  color: #4b5870;
  cursor: pointer;
}

.icon-button:hover,
.tool-button:hover,
.icon-button:focus-visible,
.tool-button:focus-visible {
  border-color: #dce4f1;
  outline: none;
  background: #f2f5fa;
  color: var(--blue);
}

.tool-button.is-active {
  border-color: color-mix(in srgb, var(--blue) 35%, #fff);
  background: #eaf0ff;
  color: var(--blue);
}

.icon-button svg,
.tool-button svg,
.page-arrow svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.home-button {
  flex: 0 0 auto;
  background: #eef3ff;
  color: var(--blue);
}

.viewer-title {
  display: flex;
  min-width: 220px;
  align-items: center;
  gap: 12px;
}

.viewer-title img {
  width: 118px;
  height: 36px;
  object-fit: contain;
}

.viewer-title div { display: grid; gap: 2px; }
.viewer-title strong { font-size: 13px; }
.viewer-title span { color: var(--muted); font-size: 10px; }

.edition-select-wrap select {
  min-height: 40px;
  padding: 0 38px 0 13px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.header-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 3px;
  margin-left: auto;
}

.zoom-output {
  width: 48px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-align: center;
}

.action-divider {
  width: 1px;
  height: 28px;
  margin: 0 7px;
  background: var(--line);
}

.color-control {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
}

.color-control input {
  width: 25px;
  height: 25px;
  padding: 2px;
  border: 1px solid #cad3e2;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
}

.viewer-stage {
  position: relative;
  min-height: 0;
  overflow: auto;
  outline: none;
  overscroll-behavior: contain;
}

.viewer-stage:focus-visible { box-shadow: inset 0 0 0 3px rgba(36, 87, 204, .28); }

.page-spread {
  display: flex;
  width: max-content;
  min-width: 100%;
  min-height: 100%;
  align-items: center;
  justify-content: center;
  padding: 34px 88px;
  transform-origin: center center;
}

.page-sheet {
  position: relative;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid #cfd6e0;
  background: #fff;
  box-shadow: 0 18px 44px rgba(24, 35, 54, .18);
}

.page-sheet:first-child { border-radius: 4px 0 0 4px; }
.page-sheet:last-child { border-radius: 0 4px 4px 0; }
.page-sheet + .page-sheet { border-left: 0; }

.pdf-canvas,
.annotation-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.annotation-canvas {
  position: absolute;
  inset: 0;
  z-index: 2;
  touch-action: none;
  pointer-events: none;
}

.page-spread[data-tool="pen"] .annotation-canvas,
.page-spread[data-tool="highlight"] .annotation-canvas,
.page-spread[data-tool="eraser"] .annotation-canvas {
  pointer-events: auto;
  cursor: crosshair;
}

.page-spread[data-tool="eraser"] .annotation-canvas { cursor: cell; }

.page-number-badge {
  position: absolute;
  z-index: 3;
  right: 10px;
  bottom: 10px;
  display: grid;
  min-width: 29px;
  height: 29px;
  padding: 0 8px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 999px;
  background: rgba(19, 31, 50, .76);
  color: #fff;
  font-size: 11px;
  font-weight: 850;
  backdrop-filter: blur(5px);
}

.loading-state,
.error-state {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 24px;
  background: var(--stage);
  color: var(--ink);
  text-align: center;
}

.loading-state span:last-child,
.error-state span { color: var(--muted); font-size: 13px; }

.loading-spinner {
  width: 42px;
  height: 42px;
  margin-bottom: 9px;
  border: 4px solid #d5dce8;
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

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

.error-state button {
  margin-top: 9px;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  background: var(--blue);
  color: #fff;
  font-weight: 850;
  cursor: pointer;
}

.page-arrow {
  position: fixed;
  z-index: 15;
  top: 50%;
  display: grid;
  width: 50px;
  height: 50px;
  padding: 0;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  box-shadow: 0 10px 24px rgba(36, 87, 204, .26);
  color: #fff;
  cursor: pointer;
  transform: translateY(-50%);
  transition: background .16s ease, transform .16s ease, opacity .16s ease;
}

.page-arrow:hover,
.page-arrow:focus-visible {
  outline: none;
  background: var(--blue-dark);
  transform: translateY(-50%) scale(1.06);
}

.page-arrow:disabled { opacity: .3; cursor: default; transform: translateY(-50%); }
.page-arrow--prev { left: 22px; }
.page-arrow--next { right: 22px; }

.viewer-footer {
  position: relative;
  z-index: 20;
  display: grid;
  min-height: 54px;
  align-items: center;
  padding: 8px 20px calc(8px + var(--safe-bottom));
  grid-template-columns: 110px minmax(100px, 520px) 150px;
  justify-content: center;
  gap: 18px;
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, .97);
}

.page-range {
  font-size: 12px;
  font-weight: 850;
  text-align: right;
}

.page-progress {
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: #e1e6ee;
}

.page-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
  transition: width .25s ease;
}

.page-jump {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.page-jump input {
  width: 54px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--ink);
  font-weight: 850;
  text-align: center;
}

.page-jump input:focus { border-color: var(--blue); outline: 3px solid rgba(36, 87, 204, .12); }

@media (max-width: 1050px) {
  .edition-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .edition-card { min-height: 230px; }
  .viewer-title div { display: none; }
  .viewer-title { min-width: 125px; }
  .header-actions { overflow-x: auto; scrollbar-width: none; }
  .header-actions::-webkit-scrollbar { display: none; }
}

@media (max-width: 760px) {
  .edition-screen { align-content: start; }
  .edition-grid { grid-template-columns: 1fr; gap: 12px; }
  .edition-card {
    min-height: 146px;
    padding: 22px 24px;
    grid-template-columns: 52px 1fr;
    align-content: center;
    column-gap: 12px;
  }
  .edition-number { grid-row: 1 / span 3; margin: 0; }
  .edition-name,
  .edition-name-ko,
  .edition-meta { grid-column: 2; }
  .edition-name { font-size: 22px; }
  .edition-name-ko { margin-top: 3px; }
  .edition-meta { margin-top: 9px; }

  .viewer-screen { min-height: 480px; }
  .viewer-header { min-height: 62px; gap: 8px; padding: 8px 10px; }
  .viewer-title { display: none; }
  .edition-select-wrap select { width: 104px; padding-left: 10px; }
  .header-actions { margin-left: 0; }
  .header-actions {
    width: 0;
    flex: 1 1 0;
  }
  .icon-button,
  .tool-button,
  .color-control { width: 38px; height: 38px; flex: 0 0 auto; }
  .zoom-output,
  .action-divider { display: none; }
  .page-spread { padding: 22px 44px; }
  .page-sheet:first-child,
  .page-sheet:last-child { border-radius: 3px; }
  .page-sheet + .page-sheet { border-left: 1px solid #cfd6e0; }
  .page-arrow { width: 42px; height: 42px; }
  .page-arrow--prev { left: 7px; }
  .page-arrow--next { right: 7px; }
  .viewer-footer {
    min-height: 50px;
    padding-inline: 12px;
    grid-template-columns: 74px minmax(70px, 1fr) 126px;
    gap: 10px;
  }
  .page-jump > span:first-child { display: none; }
  .page-range { font-size: 11px; }
}

@media (max-width: 430px) {
  .edition-header { margin-bottom: 24px; }
  .edition-header > p:last-child { font-size: 14px; }
  .viewer-footer { grid-template-columns: 70px 1fr; }
  .page-progress { display: none; }
  .page-jump { justify-self: end; }
  .color-control,
  .tool-button[data-action="clear"] { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { scroll-behavior: auto !important; transition: none !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
