:root{--ink:#382313;--paper:#f3d7a2;--brown:#70411e}*{box-sizing:border-box}body{margin:0;color:var(--ink);font:19px/1.55 Georgia,serif;background:#c9ad76;background-image:radial-gradient(#80572b24 1px,transparent 1px);background-size:11px 11px}header{position:sticky;top:0;z-index:10;background:#f5d9a6;border-bottom:4px solid #85572b;box-shadow:0 4px 12px #321a1050}nav{max-width:1200px;margin:auto;display:flex;gap:18px;align-items:center;flex-wrap:wrap;padding:12px 20px}nav a{color:#352011;text-decoration:none;padding:7px 9px}nav a:hover,nav a.active{background:#dfbd82;border-radius:8px}.brand{font-weight:bold;font-size:24px;margin-right:auto}.buy{background:#69401f;color:#fff5d8;border:3px ridge #ae8048;border-radius:8px;padding:8px 18px}main{max-width:1080px;margin:35px auto;padding:32px;background:#f4ddb1;box-shadow:0 8px 28px #49301855;border:2px solid #bd9561;border-radius:8px}h1,h2{text-align:center;color:#593014}h1{font-size:42px}h2{font-size:28px}.intro{max-width:750px;margin:0 auto 30px;text-align:center}.grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(215px,1fr));gap:20px}.tile{background:#f9e8c8;border:2px solid #c6a373;border-radius:10px;padding:17px;text-align:center;box-shadow:2px 3px 0 #c7a675}.tile a{color:#643817}.tile img{width:100%;height:195px;object-fit:contain}.muted{color:#775b3c;font-style:italic}.steps{counter-reset:step}
.step{
  display:grid;
  grid-template-columns:5% 95%;
  grid-template-rows:auto auto;
  margin:15px 0;
  padding:0;
  overflow:hidden;
  background:#f9e8c8;
  border:1px solid #cba778;
  border-radius:10px;
}
.step::before{
  counter-increment:step;
  content:counter(step);
  grid-column:1;
  grid-row:1 / span 2;
  display:flex;
  align-items:center;
  justify-content:center;
  border-right:1px solid #cba778;
  background:#dfc49a;
  color:#7e4c29;
  font-size:22px;
  font-weight:bold;
}
.step h2{
  grid-column:2;
  margin:14px 20px 2px;
  text-align:left;
  line-height:1.25;
}
.step p{
  grid-column:2;
  margin:0 20px 16px;
  text-align:left;
}
@media(max-width:650px){
  .step{grid-template-columns:minmax(34px,9%) minmax(0,1fr)}
  .step::before{font-size:20px}
  .step h2{font-size:23px;margin:13px 14px 5px}
  .step p{margin:0 14px 15px}
}table{border-collapse:collapse;width:100%;background:#f9e8c8}td,th{border:1px solid #bb9669;padding:12px;text-align:left}th{width:30%}.gallery img{width:100%;height:200px;object-fit:contain;cursor:zoom-in}.overlay{position:fixed;inset:0;background:#170f0be8;display:none;align-items:center;justify-content:center;z-index:100;padding:30px}.overlay.open{display:flex}.overlay img{max-width:95%;max-height:95%;object-fit:contain}footer{text-align:center;padding:25px}a:focus-visible,button:focus-visible{outline:3px solid #1e6ba3}@media(max-width:650px){main{margin:12px;padding:18px}h1{font-size:32px}nav{gap:3px}.brand{width:100%}}
/* Галерея: естественные размеры, колонки без обрезки */
.gallery-masonry{display:block;columns:3 230px;column-gap:14px}
.gallery-picture{display:block;width:100%;padding:0;margin:0 0 14px;break-inside:avoid;overflow:hidden;border:2px solid #bc9562;border-radius:9px;background:#f9e8c8;box-shadow:2px 3px 0 #c7a675;cursor:zoom-in;line-height:0;appearance:none;-webkit-appearance:none}
.gallery-picture img{display:block;width:100%;height:auto;object-fit:initial;max-width:none}
.gallery-picture:hover{box-shadow:0 4px 12px #58351455;transform:translateY(-1px)}
.gallery-lightbox-open{overflow:hidden}
.gallery-overlay{position:fixed;inset:0;z-index:100;background:rgba(22,13,7,.92);display:none;align-items:center;justify-content:center;padding:50px 14px 20px}
.gallery-overlay.open{display:flex}
.gallery-overlay>img{max-width:100%;max-height:100%;width:auto;height:auto;object-fit:contain;box-shadow:0 8px 32px #0009}
.gallery-close{position:absolute;top:10px;right:12px;border:1px solid #f8e8ce88;border-radius:30px;background:#f3d7a2;color:#382313;width:42px;height:42px;font:30px/1 Georgia,serif;cursor:pointer}
@media(max-width:650px){.gallery-masonry{columns:2 145px;column-gap:9px}.gallery-picture{margin-bottom:9px}}
@media(max-width:400px){.gallery-masonry{columns:1}}
/* Карточки жителей: единая вертикальная сетка и номер в одну строку */
#residents .tile {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}
#residents .tile > img {
  display: block;
  flex: 0 0 195px;
}
#residents .tile > h2 {
  min-height: 2.65em;
  margin: 12px 0 9px;
  line-height: 1.3;
  display: flex;
  align-items: center;
  justify-content: center;
}
/* Профессия и номер */
#residents .tile > p:first-of-type {
  font-size: clamp(12px, 1.3vw, 15px);
  white-space: nowrap;
  letter-spacing: -0.15px;
  margin: 0 0 10px;
}
/* Архетип: резервируем место под две строки */
#residents .tile > p:nth-of-type(2) {
  min-height: 3em;
  font-size: 17px;
  line-height: 1.5;
  margin: 0 0 12px;
}
/* Ссылка на историю или заглушка — на общей нижней линии */
#residents .tile > a,
#residents .tile > .muted {
  display: block;
  margin-top: auto;
}
/* Мобильное меню: две равные колонки, контакты и покупка отдельными строками. */
@media(max-width:700px){
  header > nav{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));column-gap:0;row-gap:2px;padding:8px 12px 12px;justify-items:stretch}
  header > nav a{display:flex;align-items:center;justify-content:center;min-width:0;margin:0;font-size:clamp(16px,4.9vw,20px);font-weight:600;line-height:1.3;min-height:44px;padding:9px 2px;text-align:center}
  header > nav .brand{grid-column:1 / -1;grid-row:1;width:100%;margin:0;font-size:clamp(20px,5.7vw,24px);padding:10px 4px 12px}
  header > nav a[href="about.html"]{grid-column:1;grid-row:2}
  header > nav a[href="residents.html"]{grid-column:2;grid-row:2}
  header > nav a[href="how.html"]{grid-column:1;grid-row:3}
  header > nav a[href="gallery.html"]{grid-column:2;grid-row:3}
  header > nav a[href="contacts.html"]{grid-column:1 / -1;grid-row:4;justify-self:center;padding:9px 12px}
  header > nav .buy{grid-column:1 / -1;grid-row:5;justify-self:center;margin:5px 0 2px;padding:9px 20px}
}

/* Анимация загрузки портретов: кружок до готовности изображения. */
#residents .resident-photo {
  position: relative;
  height: 195px;
  flex: 0 0 195px;
  width: 100%;
}
#residents .resident-photo img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0;
  transform: translateY(5px) scale(.975);
  transition: opacity .5s ease, transform .65s cubic-bezier(.2,.7,.2,1);
}
#residents .resident-photo::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 36px;
  height: 36px;
  margin: -18px 0 0 -18px;
  border: 3px solid rgba(112,65,30,.17);
  border-top-color: #85572b;
  border-right-color: #b7864c;
  border-radius: 50%;
  animation: galkino-portrait-spin .85s linear infinite;
  transition: opacity .22s ease;
  pointer-events: none;
}
#residents .resident-photo.is-loaded img {
  opacity: 1;
  transform: none;
}
#residents .resident-photo.is-loaded::after {
  opacity: 0;
  animation-play-state: paused;
}
@keyframes galkino-portrait-spin {
  to { transform: rotate(360deg); }
}
@media (prefers-reduced-motion: reduce) {
  #residents .resident-photo img { transition: none; transform: none; }
  #residents .resident-photo::after { animation: none; }
}

/* Лавка Галькино: каталог всех жителей. */
.shop-page{max-width:1170px;padding:38px 38px 46px;border-radius:16px}
.shop-heading{text-align:center;margin:0 auto 29px}
.shop-heading .shop-overline{margin:0 0 7px;color:#986a39;font-size:15px;font-weight:bold;letter-spacing:.16em;text-transform:uppercase}
.shop-heading h1{font-size:clamp(37px,5vw,55px);line-height:1.15;margin:0 0 16px}
.shop-heading>p:last-child{max-width:760px;margin:0 auto;font-size:18px;line-height:1.6}
.shop-notice{display:flex;align-items:center;gap:14px;background:#edce9b;border:1px solid #bc925e;border-radius:12px;padding:14px 19px;margin:0 0 26px}
.shop-notice-seal{flex:none;display:grid;place-items:center;width:42px;height:42px;border:2px solid #b78a51;border-radius:50%;font-size:24px;color:#79461f}
.shop-notice p{flex:1;margin:0;font-size:16px;line-height:1.5}
.shop-notice-wb{flex:none;padding:8px 12px;border-radius:7px;color:#fff5db;background:#70411e;font:bold 15px Georgia,serif}
.shop-catalog{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:18px}
.shop-card{min-width:0;display:flex;flex-direction:column;overflow:hidden;background:#f9e9ca;border:2px solid #b78a51;border-radius:13px;box-shadow:3px 5px 0 #94632f26,0 5px 16px #55321416;transition:transform .2s ease,box-shadow .2s ease}
.shop-card:hover{transform:translateY(-3px);box-shadow:3px 8px 0 #94632f24,0 9px 22px #55321422}
.shop-card-portrait{position:relative;display:flex;align-items:center;justify-content:center;height:240px;padding:31px 12px 9px;background:radial-gradient(ellipse at 50% 36%,#f8e8c7 0%,#e7c38c 82%);border-bottom:1px solid #c49a66;text-decoration:none}
.shop-card-portrait img{max-width:100%;width:100%;height:100%;object-fit:contain;filter:drop-shadow(0 6px 4px #56351d22)}
.shop-card-number{position:absolute;top:11px;left:12px;z-index:1;border:1px solid #b48755;border-radius:6px;padding:4px 8px;background:#f7e4bb;color:#754721;font:bold 12px Georgia,serif}
.shop-card-body{display:flex;flex:1;flex-direction:column;padding:17px 16px 18px}
.shop-card h2{margin:0 0 6px;color:#593014;font-size:clamp(21px,1.8vw,25px);line-height:1.18;text-align:left;min-height:2.35em}
.shop-card-job{color:#7b5434;font-size:15px;margin:0 0 9px}
.shop-card-archetype{min-height:48px;line-height:1.4;margin:0;font-size:15px;color:#6c4c2c}
.shop-card-archetype strong{font-weight:bold;color:#523419}
.shop-card-actions{display:flex;flex-direction:column;gap:12px;margin-top:auto;padding-top:16px}
.shop-card-buy{display:block;border:2px ridge #bc8d52;border-radius:8px;padding:10px 8px;background:linear-gradient(#88532c,#623819);color:#fff3d8;text-decoration:none;text-align:center;font:bold 15px Georgia,serif;box-shadow:1px 2px 3px #60422555}
.shop-card-buy:hover{background:#9b6336;color:#fff}
.shop-card-story{color:#72421e;text-decoration:underline;text-underline-offset:3px;text-align:center;font-size:14px;font-weight:bold}
.shop-endnote{margin-top:29px;padding:25px 24px;text-align:center;border-radius:12px;background:#eacb94;border:1px solid #c39a65}
.shop-endnote-symbol{color:#8c5830;font-size:24px}
.shop-endnote h2{font-size:25px;margin:2px 0 9px}
.shop-endnote p{max-width:680px;margin:0 auto 12px;font-size:16px}
.shop-endnote a{color:#69401f;font-weight:bold;text-underline-offset:3px}
@media(max-width:1050px){.shop-catalog{grid-template-columns:repeat(3,minmax(0,1fr))}}
@media(max-width:800px){.shop-page{padding:27px 23px}.shop-catalog{grid-template-columns:repeat(2,minmax(0,1fr));gap:15px}.shop-card-portrait{height:260px}}
@media(max-width:650px){.shop-page{padding:22px 15px}.shop-heading{margin-bottom:20px}.shop-heading>p:last-child{font-size:16px}.shop-notice{flex-wrap:wrap;padding:12px 14px;gap:11px}.shop-notice p{flex:1 1 calc(100% - 55px);font-size:15px}.shop-notice-wb{margin-left:auto}.shop-card-portrait{height:215px}.shop-card-body{padding:13px 12px 15px}.shop-card h2{font-size:21px}.shop-card-job,.shop-card-archetype{font-size:14px}.shop-card-buy{font-size:14px}.shop-card-story{font-size:13px}}
@media(max-width:500px){.shop-catalog{grid-template-columns:1fr;gap:16px}.shop-card{display:grid;grid-template-columns:minmax(0,40%) minmax(0,60%)}.shop-card-portrait{height:100%;min-height:250px;border-right:1px solid #c49a66;border-bottom:0;padding:37px 5px 10px}.shop-card-body{padding:16px 13px 16px}.shop-card h2{min-height:0;font-size:22px}.shop-card-archetype{min-height:0}.shop-card-actions{gap:9px}.shop-card-buy{font-size:13px;padding:10px 4px}.shop-card-story{font-size:12px}.shop-card-number{top:8px;left:6px;padding:3px 5px;font-size:10px}.shop-endnote{padding:20px 13px}.shop-endnote h2{font-size:22px}}
@media(max-width:355px){.shop-card{grid-template-columns:1fr}.shop-card-portrait{height:215px;min-height:0;border-bottom:1px solid #c49a66;border-right:0}.shop-card h2{font-size:23px}.shop-card-body{padding:15px}.shop-card-buy{font-size:15px}}
@media(prefers-reduced-motion:reduce){.shop-card{transition:none}}
