/* melody.games · 每日识字绘本 — picturebook-specific styles on top of brand
   chrome. Tokens + reset + header/brand/explore/paper-grain live in
   packages/brand/. */

:root {
  /* Italic display face used in the daily caption — hanzi-only so far. */
  --font-italic: 'Newsreader', Georgia, serif;
}

body { overflow-x: hidden; padding-bottom: 40px; }

/* view nav — compact pill toggle */
.view-nav {
  display: flex;
  gap: 4px;
  background: rgba(42,53,84,.08);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 3px;
  flex: 0 0 auto;
}
.view-btn {
  font-family: var(--font-cn);
  font-size: 15px;
  font-weight: 400;
  color: var(--ink);
  background: transparent;
  border: 0;
  padding: 5px 14px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background .15s, color .15s;
}
.view-btn:hover:not(.active) { background: rgba(42,53,84,.10); }
.view-btn.active {
  background: var(--ink);
  color: var(--paper-card);
}

/* ====== Hero (Daily view) — image is the focus ====== */
.hero {
  position: relative;
  z-index: 4;
  max-width: 760px;
  margin: 32px auto 0;
  padding: 0 24px;
  text-align: center;
}

/* ====== Image frame ====== */
.image-frame {
  position: relative;
  display: inline-block;
  max-width: 100%;
  padding: 12px;
  background: var(--paper-card);
  border-radius: 6px;
  box-shadow:
    0 1px 0 rgba(0,0,0,.05),
    0 16px 32px -14px rgba(42,53,84,.40),
    0 4px 10px -4px rgba(42,53,84,.20);
  margin-bottom: 22px;
}
.image-frame::after {
  content: ''; position: absolute; inset: 12px;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px rgba(42,53,84,.10);
  border-radius: 2px;
}

#img {
  display: block;
  max-width: min(640px, 88vw);
  max-height: 70vh;
  width: auto;
  height: auto;
  border-radius: 2px;
  background: var(--paper-2);
  cursor: zoom-in;
}
.stamp {
  position: absolute;
  top: 22px; right: 22px;
  z-index: 5;
  font-family: var(--font-cn);
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--paper-card);
  background: rgba(42,53,84,.62);
  backdrop-filter: blur(6px);
  padding: 3px 10px;
  border-radius: 999px;
}
.spinner {
  position: absolute; inset: 12px;
  display: flex; align-items: center; justify-content: center;
  min-height: 360px;
}
.spinner::after {
  content: '';
  width: 42px; height: 42px;
  border: 3px solid rgba(42,53,84,.15);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.error {
  padding: 80px 40px;
  color: var(--muted);
  font-size: 15px;
}

/* ====== Daily controls ====== */
.controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
  position: relative;
  z-index: 3;
}
.nav-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--paper-card);
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 13px;
  border: 1.5px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: transform .15s, box-shadow .15s;
}
.nav-btn .arrow { font-size: 16px; line-height: 1; }
.nav-btn:hover:not(:disabled) {
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 var(--ink);
}
.nav-btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 var(--ink);
}
.nav-btn:disabled {
  opacity: .35;
  cursor: not-allowed;
  box-shadow: 1px 1px 0 var(--ink);
}
.picker-wrap {
  display: inline-flex; align-items: center;
  padding: 6px 14px;
  background: rgba(42,53,84,.06);
  border: 1.5px dashed var(--blue);
  border-radius: 999px;
}
.picker-wrap select {
  background: transparent;
  border: none;
  outline: none;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  max-width: 240px;
}

/* ====== Wall (gallery view) ====== */
.gallery {
  position: relative;
  z-index: 4;
  max-width: 1080px;
  margin: 28px auto 0;
  padding: 0 28px 32px;
}

/* search input */
.search {
  display: flex; align-items: center; gap: 12px;
  background: var(--paper-card);
  border: 1.5px solid var(--ink);
  border-radius: 999px;
  padding: 9px 18px;
  margin-bottom: 6px;
  transition: box-shadow .15s, border-color .15s;
}
.search:focus-within {
  border-color: var(--coral);
  box-shadow: 0 0 0 3px rgba(196,123,90,.18);
}
.search-ic { width: 16px; height: 16px; color: var(--ink-3); flex: 0 0 16px; }
.search input {
  flex: 1; min-width: 0;
  border: 0; background: transparent; outline: none;
  font-family: var(--font-cn);
  font-size: 18px;
  letter-spacing: 2px;
  color: var(--ink);
}
.search input::placeholder {
  font-family: var(--font-body);
  font-size: 13px;
  color: var(--ink-3);
  letter-spacing: .5px;
  opacity: 1;
}
.search-clear {
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--ink-2); color: var(--paper-card);
  border: 0;
  font-size: 14px; line-height: 1;
  cursor: pointer;
  display: grid; place-items: center;
  flex: 0 0 22px;
}

/* paper-card chips — clothes-pin pegs, wrap-flex (no horizontal scroll) */
.quick {
  display: flex;
  flex-wrap: wrap;
  gap: 14px 12px;
  padding: 22px 4px 10px;
  margin-bottom: 8px;
}
.qchip {
  position: relative;
  padding: 8px 12px 10px;
  background: var(--paper-card);
  border: 1.5px solid var(--ink);
  border-radius: 6px;
  font-family: var(--font-cn);
  font-size: 22px;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 2px 2px 0 rgba(42,53,84,.5);
  transition: transform .18s cubic-bezier(.3,1.4,.5,1), background .15s, color .15s, box-shadow .15s;
  transform-origin: top center;
  min-width: 40px;
  text-align: center;
}
.qchip::before {
  content: '';
  position: absolute;
  top: -8px; left: 50%;
  width: 8px; height: 12px;
  background: var(--ink);
  border-radius: 2px;
  transform: translateX(-50%);
}
.qchip:nth-child(3n+2)  { transform: rotate(-2deg); }
.qchip:nth-child(3n+3)  { transform: rotate(1.5deg); }
.qchip:nth-child(5n+4)  { transform: rotate(-1deg); }
.qchip:hover {
  transform: rotate(0) translateY(-3px);
  box-shadow: 3px 4px 0 rgba(42,53,84,.5);
}
.qchip.active {
  background: var(--coral);
  color: var(--paper-card);
  border-color: var(--coral);
  transform: rotate(0) translateY(-3px);
  box-shadow: 3px 4px 0 rgba(138,75,55,.65);
}
.qchip.active::before { background: var(--coral); }

/* flat gallery grid */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  padding: 12px 0;
}
.tile {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1.5px solid var(--ink);
  box-shadow: 2px 2px 0 var(--ink);
  cursor: pointer;
  background: var(--paper-2);
  transition: transform .15s cubic-bezier(.3,1.4,.5,1), box-shadow .15s;
  padding: 0;
}
.tile:hover {
  transform: translate(-1px, -2px);
  box-shadow: 3px 4px 0 var(--ink);
}
.tile:active { transform: translate(1px, 1px); box-shadow: 1px 1px 0 var(--ink); }
.tile img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.tile .day-label {
  position: absolute;
  top: 6px; left: 8px;
  z-index: 3;
  font-family: var(--font-italic);
  font-style: italic;
  font-weight: 700;
  font-size: 13px;
  color: var(--paper-card);
  text-shadow: 0 1px 3px rgba(0,0,0,.7);
  line-height: 1;
}
.tile.latest {
  box-shadow: 0 0 0 2px var(--coral), 2px 2px 0 var(--ink);
}
.tile.latest::after {
  content: 'LATEST';
  position: absolute;
  left: 6px; right: 6px; bottom: 6px;
  z-index: 3;
  background: var(--coral);
  color: var(--paper-card);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 9px;
  letter-spacing: 2px;
  text-align: center;
  padding: 3px 0;
  border-radius: 3px;
}
.tile.is-hidden { display: none; }

.gallery-empty {
  padding: 50px 20px;
  text-align: center;
  font-family: var(--font-italic);
  font-style: italic;
  font-size: 16px;
  color: var(--ink-3);
}
.gallery-empty .ch {
  display: block;
  font-family: var(--font-cn);
  font-style: normal;
  font-size: 32px;
  color: var(--ink-2);
  margin-bottom: 8px;
  letter-spacing: 4px;
}

/* Footer: picturebook wants tighter spacing (32px vs shared 40px) and a
   wrapped body-font caption rather than the shared uppercase footer. */
.site-footer {
  margin-top: 32px;
  padding: 18px 20px;
  font-family: var(--font-cn-body);
  font-size: 12px;
  letter-spacing: .6px;
  text-transform: none;
}
.site-footer .dot { opacity: .55; }

/* ====== Lightbox ====== */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(20,18,14,.94);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 28px;
  gap: 16px;
  animation: lightbox-fade .2s ease-out;
}
@keyframes lightbox-fade { from { opacity: 0 } to { opacity: 1 } }
.lightbox-img {
  max-width: 92vw;
  max-height: 80vh;
  width: auto;
  height: auto;
  border-radius: 4px;
  box-shadow: 0 24px 60px -10px rgba(0,0,0,.6);
  background: var(--paper);
  cursor: zoom-out;
}
.lightbox-close {
  position: absolute;
  top: 22px; right: 22px;
  width: 42px; height: 42px;
  border-radius: 50%;
  background: rgba(255,250,240,.12);
  border: 1.5px solid rgba(255,250,240,.3);
  color: var(--paper);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  backdrop-filter: blur(10px);
  display: grid; place-items: center;
}
.lightbox-close:hover { background: rgba(255,250,240,.2); }
.lightbox-caption {
  text-align: center;
  color: rgba(241,231,208,.85);
  font-family: var(--font-cn);
  font-size: 14px;
  letter-spacing: 2px;
}
body.lightbox-open { overflow: hidden; }

/* ====== Mobile ====== */
@media (max-width: 720px) {
  .site-header { padding: 12px 18px; }
  .brand-mark { width: 30px; height: 30px; flex: 0 0 30px; }
  .brand-name { font-size: 17px; }
  .brand-tagline { font-size: 9px; letter-spacing: 1px; }
  .view-btn { font-size: 14px; padding: 4px 11px; }

  .hero { margin-top: 20px; padding: 0 16px; }
  .image-frame { padding: 8px; }
  .image-frame::after { inset: 8px; }
  #img { max-width: 92vw; max-height: 68vh; }
  .stamp { top: 16px; right: 16px; }
  .controls { gap: 8px; }
  .nav-btn { padding: 8px 14px; font-size: 12px; }

  .gallery { padding: 0 18px 24px; }
  .quick { padding: 18px 2px 6px; gap: 12px 10px; }
  .qchip { font-size: 19px; min-width: 36px; padding: 7px 10px 9px; }
  .gallery-grid { grid-template-columns: repeat(auto-fill, minmax(108px, 1fr)); gap: 10px; }
  .tile .day-label { font-size: 11px; }
  .tile.latest::after { font-size: 8px; padding: 2px 0; }

  .lightbox-close { top: 14px; right: 14px; }
}

@media (max-width: 480px) {
  .site-header {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "brand explore"
      "nav   nav";
    gap: 10px 12px;
    padding: 14px 18px;
  }
  .brand { grid-area: brand; }
  .explore { grid-area: explore; }
  .view-nav {
    grid-area: nav;
    justify-self: start;
  }
}

@media (max-width: 440px) {
  .nav-btn .label { display: none; }
  .nav-btn { padding: 8px 12px; }
  .brand-tagline { display: none; }
}
