/* 赛博忏悔室 · 共用样式
   三屏共用：房间、页头、页脚、纸张、按钮、守则弹窗 */

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  color-scheme: dark;
  scroll-behavior: smooth;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  min-width: 320px;
  background-color: var(--desk);
  background-image:
    radial-gradient(1100px 760px at 76% 4%, rgba(142, 89, 51, 0.18), transparent 68%),
    radial-gradient(820px 780px at 10% 92%, rgba(82, 48, 27, 0.12), transparent 72%);
  background-repeat: no-repeat;
  color: var(--cream);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.05;
  background-image: url("assets/room-grain.webp");
  background-size: 256px 256px;
  background-repeat: repeat;
}

button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button, input, textarea { -webkit-tap-highlight-color: transparent; }
img, svg { display: block; }

::selection {
  background: var(--amber);
  color: var(--ink);
}

.page {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.shell {
  width: min(1240px, calc(100% - 80px));
  margin-inline: auto;
}

.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: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  min-height: 44px;
  padding: var(--space-3) var(--space-4);
  display: inline-flex;
  align-items: center;
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font-size: var(--fs-meta);
  line-height: 1.4;
  text-decoration: none;
  transform: translateY(-180%);
  transition: transform var(--dur) var(--ease);
}

.skip-link:focus-visible { transform: translateY(0); outline-color: var(--red); }

/* ---------- 页头 ---------- */

.site-head {
  position: relative;
  z-index: 5;
  border-bottom: 1px solid var(--line-dark);
}

.head-inner {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  flex-shrink: 0;
  color: var(--cream);
  text-decoration: none;
}

.brand-mark {
  width: 31px;
  height: 31px;
  flex-shrink: 0;
  color: var(--cream);
}

.brand-mark .door-light {
  stroke: var(--red);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.brand-cn {
  font-family: var(--font-serif);
  font-size: var(--fs-body);
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: 0.08em;
}

.brand-en {
  color: var(--cream-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.head-shift {
  margin: 0;
  color: var(--cream-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  line-height: 1.5;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  flex-shrink: 0;
}

.head-status {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--cream-muted);
  font-size: var(--fs-meta);
  line-height: 1.4;
  white-space: nowrap;
}

.status-dot {
  width: 5px;
  height: 5px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 0 4px rgba(153, 52, 42, 0.12);
}

.head-status time {
  color: var(--cream);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.04em;
}

.head-rules {
  min-height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line-dark-strong);
  background: transparent;
  color: var(--cream-muted);
  font-size: var(--fs-meta);
  line-height: 1;
  letter-spacing: 0.04em;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.head-rules:hover {
  color: var(--cream);
  border-color: var(--amber);
}

.brand:hover .brand-cn { color: var(--paper); }

/* ---------- 按钮与链接 ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  min-height: 52px;
  padding: 0 var(--space-5);
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  font-weight: 500;
  line-height: 1;
  letter-spacing: 0.03em;
  text-decoration: none;
  transition:
    background var(--dur) var(--ease),
    border-color var(--dur) var(--ease),
    color var(--dur) var(--ease),
    transform var(--dur) var(--ease);
}

.btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.btn-primary {
  position: relative;
  border-color: var(--red-deep);
  background: var(--red);
  color: var(--red-ink);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.24);
}

.btn-primary::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 1px solid rgba(248, 240, 226, 0.28);
  border-radius: 1px;
  pointer-events: none;
}

.btn-primary:hover {
  background: var(--red-deep);
  border-color: var(--red-deep);
}

.btn-primary:hover svg { transform: translateX(3px); }
.btn-primary svg { transition: transform var(--dur) var(--ease); }
.btn-primary:active { transform: translateY(1px); }

.btn-text {
  min-height: 44px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border: 0;
  border-bottom: 1px solid var(--line-dark-strong);
  border-radius: 0;
  background: transparent;
  color: var(--cream-muted);
  font-size: var(--fs-meta);
  line-height: 1;
  letter-spacing: 0.04em;
  transition: color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}

.btn-text:hover {
  color: var(--cream);
  border-color: var(--amber);
}

.paper .btn-text {
  color: var(--ink-soft);
  border-bottom-color: var(--line-paper-strong);
}

.paper .btn-text:hover {
  color: var(--red-deep);
  border-color: var(--red);
}

.btn:focus-visible,
.btn-text:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

/* ---------- 纸 ---------- */

.paper {
  --focus-ring: var(--red);
  position: relative;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(125% 95% at 12% 0%, rgba(255, 251, 242, 0.28), transparent 58%),
    linear-gradient(112deg, rgba(255, 255, 255, 0.08) 0%, transparent 42%, rgba(104, 80, 49, 0.055) 100%),
    var(--paper-grain),
    var(--paper-texture);
  background-size: auto, auto, 512px 512px, cover;
  background-position: center top, center, left top, center;
  background-repeat: no-repeat, no-repeat, repeat, no-repeat;
  border: 1px solid rgba(82, 61, 38, 0.18);
  border-radius: var(--radius-paper);
  box-shadow:
    inset -26px -30px 70px rgba(97, 72, 43, 0.055),
    inset 22px 20px 60px rgba(255, 248, 235, 0.07),
    var(--shadow-paper);
}

.paper ::selection {
  background: var(--red);
  color: var(--red-ink);
}

.paper .btn-primary:focus-visible { outline-color: var(--red); }

.paper a,
.paper .text-link {
  color: var(--red-deep);
}

.paper :focus-visible {
  outline-color: var(--red);
}

/* 朱红方印 */
.seal-mark {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  background: var(--red);
  color: var(--red-ink);
  font-family: var(--font-serif);
  font-size: var(--fs-title);
  font-weight: 600;
  line-height: 1;
  transform: rotate(-3deg);
  box-shadow:
    inset 0 0 0 1px rgba(248, 240, 226, 0.12),
    inset 0 0 18px rgba(58, 13, 8, 0.16);
}

.kicker {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0;
  color: var(--cream-muted);
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  line-height: 1.5;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.kicker::before {
  content: "";
  width: 26px;
  height: 1px;
  flex-shrink: 0;
  background: currentColor;
  opacity: 0.55;
}

.kicker--paper { color: var(--ink-soft); }

/* ---------- 纸张上的编码纹 ---------- */

.barcode {
  width: 118px;
  height: 26px;
  flex-shrink: 0;
  color: var(--ink);
  opacity: 0.62;
  background: repeating-linear-gradient(
    90deg,
    currentColor 0 2px,
    transparent 2px 5px,
    currentColor 5px 6px,
    transparent 6px 10px,
    currentColor 10px 13px,
    transparent 13px 17px
  );
}

/* ---------- 页脚 ---------- */

.site-foot {
  margin-top: auto;
  border-top: 1px solid var(--line-dark);
}

.foot-inner {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-5);
  color: var(--cream-faint);
  font-size: var(--fs-meta);
  line-height: 1.7;
}

.foot-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--cream-muted);
}

.foot-dot {
  width: 6px;
  height: 6px;
  flex-shrink: 0;
  background: var(--red);
}

.foot-copy { text-align: right; }

/* ---------- 告解须知弹窗 ---------- */

.rules-dialog {
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  margin: auto;
  padding: 0;
  overflow: auto;
  border: 0;
  color: var(--ink);
}

.rules-dialog::backdrop {
  background: rgba(4, 3, 2, 0.82);
}

.rules-dialog .paper-inner {
  padding: 32px;
}

.rules-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--line-paper);
}

.rules-kicker {
  margin: 0;
  color: var(--red);
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  line-height: 1.5;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.rules-close {
  width: 44px;
  height: 44px;
  margin: -10px -10px 0 0;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-soft);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}

.rules-close:hover {
  background: rgba(33, 26, 19, 0.07);
  color: var(--ink);
}

.rules-close svg { width: 18px; height: 18px; }

.rules-dialog h2 {
  margin: var(--space-5) 0 var(--space-3);
  font-family: var(--font-serif);
  font-size: var(--fs-title);
  font-weight: 500;
  line-height: 1.6;
  letter-spacing: 0.01em;
}

.rules-lead {
  margin: 0 0 var(--space-5);
  color: var(--ink-soft);
  font-size: var(--fs-body);
  line-height: 1.8;
}

.rules-list {
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line-paper-strong);
}

.rules-list li {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  border-bottom: 1px solid var(--line-paper);
  color: var(--ink);
  font-size: var(--fs-body);
  line-height: 1.8;
}

.rules-list .rule-num {
  flex-shrink: 0;
  color: var(--red);
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  line-height: 2;
}

.rules-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin-top: var(--space-5);
}

.rules-foot span {
  color: var(--ink-soft);
  font-family: var(--font-mono);
  font-size: var(--fs-meta);
  line-height: 1.5;
  letter-spacing: 0.04em;
}

.rules-dialog[open] {
  animation: dialog-in 240ms var(--ease) both;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.99); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- 焦点与动效 ---------- */

a, button, input, textarea { -webkit-tap-highlight-color: transparent; }

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 3px;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: no-preference) {
  .reveal {
    animation: rise 560ms var(--ease) both;
  }
  .reveal--late { animation-delay: 90ms; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-delay: 0ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- 响应式 ---------- */

@media (max-width: 1120px) {
  .shell { width: calc(100% - 56px); }
}

@media (max-width: 900px) {
  .head-shift { display: none; }
}

@media (max-width: 720px) {
  .shell { width: calc(100% - 40px); }
  .head-inner { min-height: 64px; }
  .head-status { display: none; }
  .site-head { border-bottom-color: var(--line-dark); }
  .foot-inner {
    min-height: 84px;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: var(--space-1);
  }
  .foot-copy { text-align: left; }
  .rules-dialog .paper-inner { padding: var(--space-5); }
  .rules-dialog h2 { font-size: var(--fs-title); }
}

@media (max-width: 480px) {
  .brand-en { display: none; }
  .head-actions { gap: var(--space-4); }
  .btn { width: 100%; }
}
