@font-face {
  font-family: "PlexSerif";
  src: url("/assets/fonts/IBMPlexSerif-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "PlexSerif";
  src: url("/assets/fonts/IBMPlexSerif-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "PlexMono";
  src: url("/assets/fonts/IBMPlexMono-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "PlexMono";
  src: url("/assets/fonts/IBMPlexMono-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #f4efe6;
  --paper: #f7f2e9;
  --ink: #2a211a;
  --muted: #6d645d;
  --seal: #7f1d1d;
  --accent: #224f6c;
  --line: #d5cec3;
  --success: #305f3a;
  --shadow: 0 18px 36px rgba(35, 29, 22, 0.12);
  --radius: 18px;
}

body[data-city="msk"] {
  --seal: #5b1f00;
  --accent: #5a3d1a;
  --bg: #f3eee3;
  --paper: #f7f1e8;
  --ink: #2b241d;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "PlexSerif", Georgia, serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 14% 14%, rgba(127, 29, 29, 0.08), transparent 46%),
    radial-gradient(circle at 85% 2%, rgba(34, 79, 108, 0.08), transparent 35%),
    linear-gradient(180deg, #f7f2e9 0%, #eee5d7 100%);
  line-height: 1.5;
  min-height: 100dvh;
}

a {
  color: inherit;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: var(--seal);
}

.top-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  backdrop-filter: blur(6px);
  background: rgba(247, 242, 233, 0.9);
  border-bottom: 1px solid var(--line);
}

.top-bar__inner {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0.8rem 1rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
}

.logo-mark {
  display: inline-flex;
  gap: 0.55rem;
  align-items: center;
  text-decoration: none;
}

.logo-mark__seal {
  border: 2px solid var(--seal);
  color: var(--seal);
  font-family: "PlexMono", "Courier New", monospace;
  font-size: 0.74rem;
  letter-spacing: 0.1em;
  padding: 0.2rem 0.45rem;
}

.logo-mark__name {
  font-family: "PlexMono", "Courier New", monospace;
  letter-spacing: 0.06em;
  font-size: 0.85rem;
}

.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  justify-content: center;
}

.main-nav a {
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 999px;
  border: 1px solid transparent;
}

.main-nav a:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.6);
}

.city-switch {
  display: inline-flex;
  gap: 0.35rem;
  font-family: "PlexMono", "Courier New", monospace;
}

.city-switch a {
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
}

.city-switch a.is-active {
  border-color: var(--seal);
  color: var(--seal);
}

.page-main {
  max-width: 1220px;
  margin: 0 auto;
  padding: 1.4rem 1rem 3.5rem;
}

.hero-casefile {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 1.15rem;
  margin-bottom: 1.4rem;
}

.hero-casefile__folder,
.hero-index-card {
  background: var(--paper);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
}

.hero-casefile__folder {
  padding: 2rem;
  background-image:
    linear-gradient(120deg, rgba(127, 29, 29, 0.06), transparent 40%),
    repeating-linear-gradient(
      to bottom,
      transparent 0,
      transparent 29px,
      rgba(73, 57, 41, 0.08) 30px,
      transparent 31px
    );
}

.hero-casefile__folder::before {
  content: "";
  position: absolute;
  right: 1.1rem;
  top: 1rem;
  width: 108px;
  height: 9px;
  background: #d6c8b4;
  border-radius: 6px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.08);
}

.hero-casefile__folder h1 {
  font-size: clamp(1.5rem, 2.7vw, 2.4rem);
  margin: 0.5rem 0;
}

.hero-casefile__folder p {
  margin: 0.6rem 0;
  max-width: 66ch;
}

.hero-casefile__note {
  padding-left: 0.6rem;
  border-left: 3px solid var(--accent);
  color: var(--muted);
}

.hero-index-card {
  padding: 1.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.hero-index-card h2 {
  margin: 0;
  font-size: 1.15rem;
}

.section-block {
  margin-top: 1.25rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.3rem 1.2rem;
  position: relative;
}

.section-block::before {
  content: "";
  position: absolute;
  right: 18px;
  top: -11px;
  width: 112px;
  height: 24px;
  background: linear-gradient(90deg, #f5d46f 0%, #ecd07a 100%);
  border-radius: 2px;
  box-shadow: 0 4px 10px rgba(42, 33, 26, 0.14);
  transform: rotate(-1.5deg);
}

.section-head {
  margin-bottom: 0.9rem;
}

.section-head h1,
.section-head h2 {
  margin: 0 0 0.55rem;
}

.section-head p {
  margin: 0;
  color: var(--muted);
}

.search-control {
  display: block;
  font-family: "PlexMono", "Courier New", monospace;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}

input[type="search"],
textarea,
input[type="file"] {
  width: 100%;
  border-radius: 11px;
  border: 1px solid #bfb1a0;
  background: #fffcf7;
  color: var(--ink);
  font-size: 1rem;
  padding: 0.64rem 0.75rem;
  font-family: "PlexSerif", Georgia, serif;
}

textarea {
  resize: vertical;
}

.mini-result {
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.mini-result li a {
  display: block;
  padding: 0.52rem 0.65rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fffdf9;
  text-decoration: none;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-top: 1.1rem;
}

.btn {
  cursor: pointer;
  border: 1px solid #b4a896;
  border-radius: 999px;
  background: #fffefb;
  padding: 0.48rem 0.86rem;
  color: var(--ink);
  text-decoration: none;
  font-family: "PlexMono", "Courier New", monospace;
  font-size: 0.84rem;
}

.btn:hover {
  border-color: var(--seal);
  color: var(--seal);
}

.btn--primary {
  background: var(--seal);
  color: #fff;
  border-color: var(--seal);
}

.btn--primary:hover {
  background: #701414;
  color: #fff;
}

.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.case-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffcf8;
  padding: 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  animation: cardRise 0.45s ease both;
  animation-delay: var(--delay, 0s);
}

.case-card h3 {
  margin: 0;
  font-size: 1rem;
}

.case-card p {
  margin: 0;
  color: var(--muted);
}

.case-card a {
  font-family: "PlexMono", "Courier New", monospace;
  font-size: 0.83rem;
}

.case-card__index {
  margin: 0;
  font-family: "PlexMono", "Courier New", monospace;
  font-size: 0.73rem;
  letter-spacing: 0.08em;
  color: #7a6957;
  text-transform: uppercase;
}

.items-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.48rem;
}

.item-chip {
  border: 1px dashed #a6917d;
  border-radius: 999px;
  padding: 0.36rem 0.6rem;
  text-decoration: none;
  background: rgba(255, 255, 255, 0.5);
  font-size: 0.9rem;
}

.timeline-list {
  margin: 0;
  padding-left: 1.15rem;
  display: grid;
  gap: 0.5rem;
}

.stamp {
  display: inline-block;
  border: 2px solid var(--seal);
  color: var(--seal);
  font-family: "PlexMono", "Courier New", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 6px;
  padding: 0.2rem 0.42rem;
  transform: rotate(-2deg);
  width: fit-content;
  background: rgba(255, 255, 255, 0.55);
}

.stamp--animated {
  animation: stampPop 0.5s cubic-bezier(0.18, 1.05, 0.2, 1.02);
}

.case-cover {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
  padding: 1.3rem;
  display: grid;
  grid-template-columns: 1.3fr 0.8fr;
  gap: 1rem;
}

.folder-meta {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.8rem;
  background: #fffdf9;
}

.folder-meta p {
  margin: 0.22rem 0;
}

.tags-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.8rem;
}

.tags-row span {
  border: 1px dashed #9f8a76;
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  font-size: 0.84rem;
}

.sheet-nav {
  margin-top: 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.42rem;
}

.sheet-nav button {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fffcf7;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font-family: "PlexMono", "Courier New", monospace;
  font-size: 0.75rem;
}

.sheet-nav button[aria-current="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.sheet-stack {
  margin-top: 0.82rem;
  position: relative;
  min-height: 300px;
}

.sheet {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdfa;
  padding: 1rem;
  box-shadow: 0 10px 22px rgba(40, 30, 24, 0.08);
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: perspective(900px) rotateY(-10deg) translateX(18px);
  transform-origin: left center;
  transition: transform 0.42s ease, opacity 0.34s ease;
}

.sheet.is-visible {
  opacity: 1;
  transform: perspective(900px) rotateY(0deg) translateX(0px);
  z-index: 2;
}

.sheet header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
}

.sheet h2 {
  margin: 0;
}

.sheet p {
  margin: 0.75rem 0;
}

.sheet-controls {
  display: flex;
  gap: 0.5rem;
}

.sheet-controls button {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.4rem 0.62rem;
  background: #fffefb;
  cursor: pointer;
}

.sheet-controls button:disabled {
  opacity: 0.45;
  cursor: default;
}

.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 0.65rem;
}

.item-card {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fffcf8;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.36rem;
}

.item-card h2 {
  margin: 0;
  font-size: 1rem;
}

.item-card p {
  margin: 0;
  color: var(--muted);
}

.item-card[data-hidden="true"] {
  display: none;
}

.item-detail {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.2rem;
}

.item-detail section + section {
  margin-top: 1.1rem;
}

.item-detail h1,
.item-detail h2 {
  margin: 0 0 0.55rem;
}

.item-detail .lead {
  margin: 0;
  color: var(--muted);
}

.item-detail ol,
.item-detail ul {
  margin: 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.4rem;
}

.act-layout {
  display: grid;
  grid-template-columns: 1.1fr 1fr 0.88fr;
  gap: 0.8rem;
}

.act-sheet {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
  padding: 0.8rem;
}

.act-sheet h2 {
  margin: 0 0 0.65rem;
  font-size: 1.03rem;
}

.act-item-list {
  max-height: 420px;
  overflow: auto;
  border: 1px dashed #c3b29f;
  border-radius: 10px;
  padding: 0.45rem;
  display: grid;
  gap: 0.35rem;
}

.act-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.4rem;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
}

.act-item input {
  margin: 0;
}

.act-item em {
  font-style: normal;
  font-family: "PlexMono", "Courier New", monospace;
  color: var(--muted);
  font-size: 0.75rem;
}

.act-item[data-hidden="true"] {
  display: none;
}

.condition-list {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.7rem;
}

.condition-list label {
  display: flex;
  gap: 0.5rem;
}

.act-sheet--result {
  background:
    linear-gradient(160deg, rgba(127, 29, 29, 0.06), transparent 56%),
    #fffdf8;
}

.result-log {
  margin-top: 0.8rem;
  padding: 0.6rem;
  border: 1px dashed #aa9079;
  border-radius: 10px;
  min-height: 112px;
  font-size: 0.93rem;
}

.guide-list {
  display: grid;
  gap: 0.74rem;
}

.guide-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffcf8;
  padding: 0.85rem;
}

.guide-card h2 {
  margin: 0.2rem 0;
}

.rules-list {
  display: grid;
  gap: 0.7rem;
}

.rule-card {
  border-left: 4px solid var(--accent);
  padding: 0.3rem 0 0.3rem 0.75rem;
}

.paper-note {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffdf8;
  padding: 0.9rem;
}

.print-document {
  max-width: 850px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid #c8b8a6;
  border-radius: 10px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.print-header h1,
.print-header p,
.print-document h2,
.print-document p {
  margin: 0 0 0.5rem;
}

.print-document ol,
.print-document ul {
  margin: 0;
  padding-left: 1.1rem;
}

.print-actions {
  margin-top: 1.1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.site-footer {
  border-top: 1px solid var(--line);
  background: rgba(242, 234, 221, 0.94);
  padding: 1.1rem 1rem 1.9rem;
}

.site-footer__inner {
  max-width: 1220px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
}

.site-footer h2 {
  margin: 0 0 0.45rem;
  font-size: 1rem;
}

.site-footer p {
  margin: 0.3rem 0;
}

.muted {
  color: var(--muted);
}

@keyframes stampPop {
  0% {
    transform: scale(1.35) rotate(-7deg);
    opacity: 0;
    filter: blur(2px);
  }
  100% {
    transform: scale(1) rotate(-2deg);
    opacity: 1;
    filter: blur(0);
  }
}

@keyframes cardRise {
  0% {
    transform: translateY(12px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (max-width: 980px) {
  .top-bar__inner {
    grid-template-columns: 1fr;
  }

  .main-nav {
    justify-content: flex-start;
  }

  .hero-casefile,
  .case-cover,
  .act-layout,
  .site-footer__inner {
    grid-template-columns: 1fr;
  }

  .sheet-stack {
    min-height: 360px;
  }
}

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

  .sheet {
    transform: none !important;
  }
}

@media print {
  .top-bar,
  .site-footer,
  .no-print,
  .btn,
  .sheet-controls,
  .sheet-nav {
    display: none !important;
  }

  body {
    background: #fff;
    padding: 0;
  }

  .page-main {
    max-width: none;
    padding: 0;
  }

  .print-document {
    border: 0;
    box-shadow: none;
    margin: 0;
    width: 100%;
  }
}
