/* ColoringTopia (PenColor Engine) — Site Styles */

:root {
  --bg:#FAFAF8;
  --surface:#FFFFFF;
  --soft:#F4F6FC;
  --ink:#20242C;
  --ink-soft:#5C6472;
  --ink-faint:#8A919E;
  --line:#E2E5EA;
  --line-strong:#C6CBD4;
  --brand:#3D5CC9;
  --brand-hover:#2C4199;
  --brand-wash:#EEF1FC;
  --good:#287A57;
  --good-wash:#EAF6F0;
  --focus:#7895F5;

  --s1:4px; --s2:8px; --s3:12px; --s4:16px; --s5:20px;
  --s6:24px; --s7:32px; --s8:40px; --s9:48px; --s10:64px; --s11:80px;

  --r-sm:8px; --r-md:12px; --r-lg:16px; --r-pill:999px;
  --container:1200px;
  --tap:44px;
  --paper-ratio:210/279;
}

*,*::before,*::after { box-sizing:border-box }

body {
  margin:0;
  background:var(--bg);
  color:var(--ink);
  font-family:Inter,system-ui,-apple-system,"Segoe UI",sans-serif;
  font-size:16px;
  line-height:1.6;
  -webkit-font-smoothing:antialiased;
}

a { color:inherit; text-decoration:none }
img { display:block; max-width:100% }
ul { list-style:none; margin:0; padding:0 }
button,input,select,textarea { font:inherit }
:focus-visible { outline:3px solid var(--focus); outline-offset:3px; border-radius:4px }

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

.skip-link {
  position:absolute; left:var(--s4); top:-60px; z-index:100;
  background:var(--brand); color:#fff; padding:10px 16px;
  border-radius:0 0 var(--r-sm) var(--r-sm); font-weight:600;
  transition:top .15s;
}
.skip-link:focus { top:0 }

.container { width:min(var(--container), calc(100% - 64px)); margin-inline:auto }

h1,h2,h3 { margin:0; letter-spacing:-.022em; text-wrap:balance }
h1 { font-size:clamp(28px,3.4vw,36px); line-height:1.18 }
h2 { font-size:clamp(22px,2.6vw,28px); line-height:1.24 }
h3 { font-size:19px; line-height:1.3; font-weight:600 }
p { margin:0 }

/* ---------- header ---------- */
.site-header {
  background:rgba(255,255,255,.97);
  border-bottom:1px solid var(--line);
  position:sticky; top:0; z-index:50;
}
.header-row { min-height:68px; display:flex; align-items:center; gap:var(--s6) }
.brand { display:inline-flex; align-items:center; gap:9px; font-weight:700; white-space:nowrap; letter-spacing:-.02em }
.brand-mark {
  width:34px; height:34px; border-radius:10px; background:var(--brand);
  display:grid; place-items:center; color:#fff; font-weight:700;
}
.nav { display:flex; align-items:center }
.nav-list { display:flex; align-items:center; gap:2px }
.nav a { display:block; padding:9px 11px; border-radius:8px; font-size:14px; font-weight:600; color:#3d4350 }
.nav a:hover { background:var(--soft) }
.nav .current-menu-item > a { color:var(--brand); background:var(--brand-wash) }
.header-search { margin-left:auto; width:min(300px,26vw); position:relative }
.header-search input {
  width:100%; height:42px; border:1px solid var(--line); background:#fff;
  border-radius:10px; padding:0 40px 0 13px; color:var(--ink);
}
.header-search input:focus { border-color:var(--brand) }
.search-icon {
  position:absolute; right:12px; top:50%; transform:translateY(-50%);
  width:18px; height:18px; color:var(--ink-faint); pointer-events:none;
}

.pack-link {
  display:inline-flex; align-items:center; gap:7px; min-height:var(--tap);
  padding:0 14px; border-radius:10px; background:var(--brand-wash);
  color:var(--brand); font-weight:700; font-size:14px;
}
.pack-link:hover { background:#e2e8fa }
.pack-count {
  min-width:22px; height:22px; padding:0 6px; border-radius:var(--r-pill);
  background:var(--brand); color:#fff; font-size:12px; font-weight:700;
  display:none; place-items:center; font-variant-numeric:tabular-nums;
}
.pack-count.has-items { display:grid }

.mobile-actions,.mobile-menu { display:none }
.icon-button {
  width:var(--tap); height:var(--tap); border:1px solid var(--line);
  border-radius:10px; background:#fff; display:grid; place-items:center;
  color:var(--ink); cursor:pointer;
}
.mobile-search input {
  width:100%; height:42px; border:1px solid var(--line); border-radius:10px;
  padding:0 13px; margin-bottom:10px; background:#fff;
}
.mobile-menu-list { display:flex; flex-direction:column; gap:4px }
.mobile-menu-list a { display:block; padding:10px 12px; border-radius:8px; font-weight:600; color:#3d4350 }
.mobile-menu-list a:hover { background:var(--soft) }

/* ---------- topic bar ---------- */
.topic-bar { border-top:1px solid var(--line); background:var(--surface) }
.topic-bar-list {
  display:flex; gap:var(--s1); overflow-x:auto; scrollbar-width:none;
  padding:7px 0; scroll-snap-type:x proximity;
}
.topic-bar-list::-webkit-scrollbar { display:none }
.topic-bar-list li { flex:0 0 auto; scroll-snap-align:start }
.topic-bar-list a {
  display:block; padding:7px 12px; border-radius:var(--r-pill);
  font-size:13.5px; font-weight:600; color:var(--ink-soft); white-space:nowrap;
}
.topic-bar-list a:hover { background:var(--soft); color:var(--ink) }
.topic-bar-list a[aria-current="page"] { background:var(--brand-wash); color:var(--brand) }

/* ---------- structure ---------- */
main { padding-bottom:var(--s10) }
.section { margin-top:var(--s10) }
.section-head { display:flex; align-items:end; justify-content:space-between; gap:var(--s5); margin-bottom:var(--s5) }
.kicker {
  font-size:12.5px; font-weight:700; letter-spacing:.08em; text-transform:uppercase;
  color:var(--brand); margin:0 0 6px;
}
.muted { color:var(--ink-soft) }
.small { font-size:14px }

.breadcrumb {
  display:flex; align-items:center; gap:var(--s2); padding:var(--s5) 0 var(--s4);
  color:var(--ink-faint); font-size:13px; white-space:nowrap;
  overflow-x:auto; scrollbar-width:none;
}
.breadcrumb::-webkit-scrollbar { display:none }
.breadcrumb a:hover { color:var(--brand) }

.notice {
  background:var(--surface); border:1px solid var(--line); border-radius:var(--r-lg);
  padding:var(--s7); text-align:center; display:flex; flex-direction:column; gap:var(--s3); align-items:center;
}
.bridge {
  background:linear-gradient(135deg, #eef2ff 0%, #fae8ff 100%);
  border:1px solid #c7d2fe; border-radius:20px; padding:32px;
  display:flex; align-items:center; justify-content:space-between; gap:24px; flex-wrap:wrap;
}
.actions { display:grid; gap:12px }

.pagination {
  display:flex; justify-content:center; align-items:center; gap:8px; flex-wrap:wrap;
  margin-top:var(--s8);
}
.pagination a, .pagination span {
  min-width:40px; height:40px; padding:0 12px; border-radius:10px;
  border:1px solid var(--line); background:#fff;
  display:inline-flex; align-items:center; justify-content:center;
  font-size:14px; font-weight:600; color:var(--ink);
}
.pagination a:hover { border-color:var(--brand); color:var(--brand); background:var(--brand-wash) }
.pagination .current { background:var(--brand); color:#fff; border-color:var(--brand) }

.prose p { margin-bottom:16px }
.prose h2 { margin-top:28px; margin-bottom:12px; color:#0f172a }
.prose ul { list-style:disc; padding-left:22px; margin-bottom:16px }
.prose li { margin-bottom:8px }

/* ---------- grids ---------- */
.grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:var(--s6) }
.grid-discovery { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:var(--s4) }

.card {
  background:var(--surface); border:1px solid var(--line); border-radius:var(--r-md);
  overflow:hidden; display:flex; flex-direction:column; height:100%; min-width:0;
  transition:border-color .15s, box-shadow .15s, transform .15s;
}
.card:hover { border-color:var(--line-strong); box-shadow:0 8px 22px rgba(32,36,44,.07); transform:translateY(-1px) }
.card-image { aspect-ratio:var(--paper-ratio); background:#fff; border-bottom:1px solid var(--line); display:block }
.card-image img { width:100%; height:100%; object-fit:contain }
.card-body { padding:12px 13px 13px; display:flex; flex-direction:column; gap:var(--s3); flex:1 }
.card-title {
  font-size:15px; line-height:1.35; font-weight:600; margin:0;
  display:-webkit-box; -webkit-line-clamp:2; -webkit-box-orient:vertical; overflow:hidden;
}
.card-meta { font-size:13px; color:var(--ink-faint) }

.tile {
  min-height:104px; background:var(--surface); border:1px solid var(--line);
  border-radius:var(--r-md); padding:var(--s4);
  display:grid; grid-template-columns:42px minmax(0,1fr) auto; align-items:center; gap:13px;
  transition:border-color .15s, box-shadow .15s, transform .15s;
}
.tile:hover { border-color:var(--line-strong); box-shadow:0 8px 22px rgba(32,36,44,.07); transform:translateY(-1px) }
.tile-icon {
  width:42px; height:42px; border-radius:11px; background:var(--brand-wash);
  display:grid; place-items:center; color:var(--brand); font-weight:700;
}
.tile strong { display:block; font-size:15px; line-height:1.32 }
.tile small { display:block; color:var(--ink-faint); font-size:12px; margin-top:2px }
.tile-arrow { color:var(--brand); font-weight:700 }

/* ---------- buttons ---------- */
.btn {
  min-height:48px; border-radius:10px; padding:0 18px; border:1px solid transparent;
  display:inline-flex; align-items:center; justify-content:center; gap:9px;
  font-size:15px; font-weight:700; cursor:pointer; text-align:center; transition: all 0.15s ease;
}
.btn-primary { background:var(--brand); color:#fff }
.btn-primary:hover { background:var(--brand-hover) }
.btn-secondary { background:#fff; color:var(--brand); border-color:#bfc9ef }
.btn-secondary:hover { background:var(--brand-wash) }
.btn-tertiary { background:transparent; color:var(--brand); min-height:var(--tap); padding:0 10px }
.btn-tertiary:hover { background:var(--brand-wash) }
.btn[disabled] { opacity:.5; cursor:not-allowed }
.btn.is-added { background:var(--good-wash); color:var(--good); border-color:#b6ddc9 }

.card .btn-tertiary { justify-content:flex-start; padding:0; min-height:32px; font-size:13.5px }

.btn-quick-view {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%) translateY(10px);
  background: rgba(15, 23, 42, 0.85); backdrop-filter: blur(4px); color: #fff;
  border: none; border-radius: 99px; padding: 6px 14px; font-size: 13px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  opacity: 0; transition: all 0.2s ease; z-index: 5;
}
.card:hover .btn-quick-view { opacity: 1; transform: translateX(-50%) translateY(0); }
.btn-quick-view:hover { background: #4f46e5; }

/* Sticky Pack Bar Drawer */
.sticky-pack-bar {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  width: min(1000px, calc(100% - 32px));
  background: rgba(15, 23, 42, 0.92); backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.15); border-radius: 20px;
  padding: 12px 20px; z-index: 90; box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  color: #fff; transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.sticky-pack-bar[hidden] { display: none; }
.sticky-pack-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin: 0; width: 100%; }
.sticky-pack-info { display: flex; align-items: center; gap: 16px; }
.sticky-pack-thumbs { display: flex; }
.sticky-thumb { width: 38px; height: 48px; object-fit: contain; background: #fff; border-radius: 6px; border: 2px solid #fff; margin-right: -10px; box-shadow: 0 2px 6px rgba(0,0,0,0.2); }
.sticky-pack-text strong { display: block; font-size: 15px; color: #fff; }
.sticky-pack-text small { color: #94a3b8; font-size: 13px; }
.sticky-pack-actions { display: flex; gap: 10px; }

/* Lightbox Quick View Modal */
.modal-overlay {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(15, 23, 42, 0.7); backdrop-filter: blur(8px);
  display: flex; align-items: center; justify-content: center; padding: 20px;
  opacity: 0; pointer-events: none; transition: opacity 0.25s ease;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal-overlay[hidden] { display: none; }
.modal-card {
  background: #ffffff; border-radius: 24px; max-width: 840px; width: 100%;
  max-height: 90vh; overflow-y: auto; position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); border: 1px solid #e2e8f0;
}
.modal-close {
  position: absolute; top: 16px; right: 20px; width: 36px; height: 36px;
  border-radius: 50%; background: #f1f5f9; border: none; font-size: 24px;
  color: #475569; display: flex; align-items: center; justify-content: center;
  cursor: pointer; z-index: 10; transition: background 0.2s;
}
.modal-close:hover { background: #e2e8f0; color: #0f172a; }
.modal-body { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; padding: 32px; }
.modal-image-col { background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 16px; padding: 16px; aspect-ratio: 210/279; display: flex; align-items: center; justify-content: center; }
.modal-image-col img { max-width: 100%; max-height: 100%; object-fit: contain; }
.modal-info-col { display: flex; flex-direction: column; justify-content: center; }
.modal-title { font-size: 26px; font-weight: 800; color: #0f172a; margin-bottom: 12px; }
.modal-desc { font-size: 15px; color: #64748b; margin-bottom: 24px; line-height: 1.6; }
.modal-actions { display: flex; flex-direction: column; gap: 12px; }
.modal-actions .btn { width: 100%; justify-content: center; }

/* ---------- Footer ---------- */
.site-footer {
  margin-top: 80px;
  background: #0f172a;
  color: #94a3b8;
  padding-top: 64px;
  padding-bottom: 40px;
  border-top: 1px solid #1e293b;
}
.footer-grid { display: grid; grid-template-columns: 1.8fr 1fr 1fr 1fr; gap: 40px; margin-bottom: 48px; }
.footer-brand .brand { color: #ffffff; font-size: 20px; margin-bottom: 14px; }
.footer-brand .brand-mark { background: #6366f1; }
.footer-tagline { font-size: 14px; line-height: 1.6; color: #94a3b8; margin-bottom: 20px; max-width: 340px; }
.footer-licence-card { display: flex; align-items: flex-start; gap: 12px; background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 14px; max-width: 340px; }
.licence-icon { width: 24px; height: 24px; border-radius: 50%; background: #10b981; color: #ffffff; font-weight: 800; font-size: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.footer-licence-card strong { display: block; font-size: 13px; color: #f8fafc; margin-bottom: 2px; }
.footer-licence-card small { display: block; font-size: 12px; color: #94a3b8; line-height: 1.4; }
.footer-heading { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: #cbd5e1; margin-bottom: 16px; }
.footer-links { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 10px; }
.footer-links a { color: #94a3b8; font-size: 14.5px; text-decoration: none; transition: color 0.15s ease; }
.footer-links a:hover { color: #818cf8; }
.footer-bottom { border-top: 1px solid #1e293b; padding-top: 28px; display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 16px; font-size: 13.5px; color: #64748b; }
.footer-bottom-meta { display: flex; align-items: center; gap: 16px; }
.paper-badge { background: #1e293b; color: #cbd5e1; font-size: 12px; font-weight: 600; padding: 4px 10px; border-radius: 99px; border: 1px solid #334155; }
.footer-bottom-meta a { color: #94a3b8; text-decoration: underline; text-underline-offset: 3px; }
.footer-bottom-meta a:hover { color: #818cf8; }

/* ---------- detail responsive ---------- */
.detail-grid { display:grid; grid-template-columns: minmax(0, 1fr) 420px; gap:40px; align-items:start; }

/* ---------- toast ---------- */
.toast {
  position:fixed; left:50%; bottom:24px; transform:translate(-50%,18px);
  background:#20242C; color:#fff; padding:11px 16px; border-radius:10px; font-size:14px;
  opacity:0; pointer-events:none; transition:.18s ease; z-index:100;
  max-width:calc(100% - 32px); text-align:center;
}
.toast.show { opacity:1; transform:translate(-50%,0) }

/* ---------- responsive ---------- */
@media (max-width:980px) {
  .container { width:min(var(--container), calc(100% - 48px)) }
  .nav, .header-search { display:none }
  .pack-link-label { display:none }
  .pack-link { margin-left:auto; padding:0 12px }
  .mobile-actions { display:flex; gap:var(--s2) }
  .mobile-menu { display:none; border-top:1px solid var(--line); padding:12px 0 14px }
  .mobile-menu.open { display:block }
  .grid { grid-template-columns:repeat(3,minmax(0,1fr)); gap:var(--s5) }
  .grid-discovery { grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px }
  .footer-grid { grid-template-columns: 1fr 1fr; gap: 32px; }
  .detail-grid { grid-template-columns: 1fr; gap: 28px; }
}

@media (max-width:767px) {
  .container { width:calc(100% - 32px) }
  .header-row { min-height:60px; gap:var(--s3) }
  .section { margin-top:var(--s9) }
  .grid { grid-template-columns:repeat(2,minmax(0,1fr)); gap:var(--s3) }
  .grid-discovery { grid-template-columns:repeat(2,minmax(0,1fr)); gap:var(--s3) }
  .card-body { padding:11px }
  .card-title { font-size:14px }
  .tile { min-height:84px; padding:var(--s3); grid-template-columns:36px minmax(0,1fr) }
  .modal-body { grid-template-columns:1fr; gap:20px; padding:20px; }
  .sticky-pack-text small { display:none; }
  .sticky-thumb { display:none; }
  .footer-grid { grid-template-columns: 1fr; gap: 28px; }
  .footer-bottom { flex-direction: column; align-items: flex-start; }
}

@media print {
  .site-header, .site-footer, .actions, .bridge, .ad-slot, .toast, .breadcrumb, .sticky-pack-bar, .modal-overlay { display:none !important }
}
