/* ============================================================
   websit shared styles — 田园核风 (pastoral design system)
   Used by: software/games/tutorials/search/play/admin pages.
   Homepage uses css/home.css (parallax layout, same palette).
   All original class contracts preserved so page JS works unchanged.
   ============================================================ */

:root {
  /* colors — pastoral */
  --color-meadow: #5a8f5a;
  --color-cloth: #faf6f0;
  --color-wheat: #f5d75f;
  --color-timber: #8b7355;
  --color-wild-rose: #d4a0a0;
  --color-sprout: #7ff77e;

  /* legacy aliases used by shared JS inline styles */
  --bg: var(--color-cloth);
  --card: #fffdf8;
  --ink: #3d3a34;
  --muted: #7a7266;
  --line: rgba(139, 115, 85, .22);
  --brand: var(--color-meadow);
  --brand-dark: #4a7a4a;
  --ok: #3f8a4f;
  --warn: #c08f2d;
  --bad: #b0605f;

  /* typography */
  --font-serif: 'Lora', Georgia, 'Songti SC', 'SimSun', serif;

  --text-heading: clamp(24px, 4vw, 32px);
  --text-body: 17px;
  --text-label: 15px;

  /* spacing & layout */
  --page-max: 1120px;

  /* radii */
  --radius-card: 24px;
  --radius-btn: 999px;
  --radius-input: 16px;

  /* elevation (pastoral soft) */
  --shadow: 0 4px 10px rgba(90, 143, 90, .16);
  --shadow-lg: 0 8px 20px rgba(90, 143, 90, .26);
  --shadow-card: 0 24px 60px rgba(90, 143, 90, .16);

  /* linen texture + floral sprig (identity marker) */
  --linen: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.05'/%3E%3C/svg%3E");
  --sprig: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M8 26 C12 20 16 12 22 6' stroke='%235a8f5a' stroke-width='1.8' fill='none' stroke-linecap='round'/%3E%3Cellipse cx='12' cy='18' rx='4.6' ry='2.4' transform='rotate(-28 12 18)' fill='%235a8f5a' opacity='.45'/%3E%3Cellipse cx='18' cy='12' rx='4' ry='2.1' transform='rotate(24 18 12)' fill='%23d4a0a0' opacity='.6'/%3E%3Ccircle cx='24' cy='5' r='2' fill='%23f5d75f'/%3E%3C/svg%3E");
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
[hidden] { display: none !important; }

body {
  font-family: var(--font-serif);
  background:
    radial-gradient(900px 420px at 85% -10%, rgba(245, 215, 95, .18), transparent 60%),
    radial-gradient(820px 400px at 8% 108%, rgba(90, 143, 90, .14), transparent 60%),
    var(--color-cloth) var(--linen) repeat;
  color: var(--ink);
  font-size: var(--text-body);
  line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

a { color: var(--color-meadow); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.3; letter-spacing: .01em; }

::selection { background: rgba(90, 143, 90, .25); }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid var(--color-meadow);
  outline-offset: 2px;
  border-radius: 6px;
}

.container { max-width: var(--page-max); margin: 0 auto; padding: 0 20px; }

/* ---------------- page main: fill viewport below sticky header ---------------- */
main.container {
  min-height: calc(100vh - 64px);
  min-height: calc(100dvh - 64px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 6vh, 64px) 20px clamp(40px, 8vh, 72px);
}

/* ---------------- page title (with sprig + stitched rule) ---------------- */
.page-title {
  position: relative;
  display: inline-block;
  font-size: var(--text-heading);
  margin: 0 0 20px;
  padding-left: 36px;
}
.page-title::before {
  content: ''; position: absolute; left: 0; top: 50%;
  width: 26px; height: 26px;
  transform: translateY(-50%) rotate(-8deg);
  background: var(--sprig) center/contain no-repeat;
}
.page-title::after {
  content: ''; position: absolute; left: 36px; right: 0; bottom: -8px;
  border-bottom: 2px dashed rgba(90, 143, 90, .3);
}

/* ---------------- header ---------------- */
.site-header {
  position: sticky; top: 0; z-index: 80;
  background: rgba(250, 246, 240, .86);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 2px dashed rgba(90, 143, 90, .28);
}
.site-header .container {
  display: flex; align-items: center; gap: 24px; min-height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 20px; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand .logo {
  width: 32px; height: 32px; border-radius: 999px; flex: none;
  background: rgba(90, 143, 90, .14);
  display: inline-flex; align-items: center; justify-content: center;
}
.brand .logo svg { width: 20px; height: 20px; }
.nav { display: flex; gap: 6px; margin-left: 8px; flex-wrap: wrap; }
.nav a {
  padding: 8px 16px; border-radius: 999px;
  color: var(--ink); font-weight: 600; font-size: 15px;
}
.nav a:hover { background: rgba(90, 143, 90, .12); text-decoration: none; }
.nav a.active { background: var(--color-meadow); color: var(--color-cloth); }
.header-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.btn-outline {
  border: 1px solid rgba(139, 115, 85, .30); background: #fffdf8; color: var(--ink);
  padding: 7px 14px; border-radius: var(--radius-btn); font-size: 14px; cursor: pointer;
  font-family: inherit; font-weight: 600;
  transition: border-color .3s ease, color .3s ease, transform .3s ease;
}
.btn-outline:hover { border-color: var(--color-meadow); color: var(--color-meadow); text-decoration: none; transform: translateY(-1px); }

/* ---------------- buttons (meadow button) ---------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; cursor: pointer;
  background: var(--color-meadow); color: var(--color-cloth);
  border-radius: var(--radius-btn);
  padding: 10px 24px;
  font-family: inherit; font-size: var(--text-label); font-weight: 600;
  box-shadow: 0 4px 10px rgba(90, 143, 90, .20);
  transition: transform .5s ease-in-out, box-shadow .5s ease-in-out, background .5s ease-in-out;
}
.btn:hover { transform: translateY(-2px) rotate(.8deg); box-shadow: 0 8px 20px rgba(90, 143, 90, .30); text-decoration: none; }
.btn:active { transform: rotate(0) scale(.97); box-shadow: 0 2px 6px rgba(90, 143, 90, .20); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-sm { padding: 7px 16px; font-size: 14px; }
.btn-ghost { background: #fffdf8; color: var(--ink); border: 1px solid rgba(139, 115, 85, .25); }
.btn-ghost:hover { background: rgba(90, 143, 90, .10); border-color: var(--color-meadow); }
.btn-danger { background: #b0605f; }
.btn-danger:hover { background: #96504f; }
.btn-ok { background: #3f8a4f; }
.btn-ok:hover { background: #34703f; }
.btn-warn { background: #c08f2d; }
.btn-warn:hover { background: #a67a22; }

/* ---------------- hero / search ---------------- */
.hero { text-align: center; padding: 56px 20px 44px; }
.hero h1 { font-size: var(--text-heading); margin: 0 0 10px; }
.hero p { color: var(--muted); max-width: 620px; margin: 0 auto 26px; }
.search-bar {
  display: flex; gap: 10px;
  max-width: 640px;
}
.search-bar input {
  flex: 1;
  background: #fffdf8;
  border: 1px solid rgba(139, 115, 85, .28);
  border-radius: var(--radius-input);
  padding: 12px 18px;
  font-size: var(--text-body);
  font-family: inherit; color: var(--ink);
  outline: none;
  transition: border-color .3s ease, box-shadow .3s ease;
}
.search-bar input::placeholder { color: rgba(139, 115, 85, .55); }
.search-bar input:focus {
  border-color: var(--color-meadow);
  box-shadow: 0 0 0 3px rgba(90, 143, 90, .15);
}
.search-bar button { border-radius: var(--radius-btn); padding: 10px 22px; }

/* ---------------- sections ---------------- */
.section { margin: 34px 0; }
.section-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 16px; position: relative; }
.section-head h2 { font-size: var(--text-heading); margin: 0; }
.section-head .more { margin-left: auto; font-size: 15px; font-weight: 600; color: var(--color-meadow); }
.section-head .count-badge {
  font-size: 13px; color: var(--color-timber);
  background: rgba(90, 143, 90, .12);
  padding: 3px 12px; border-radius: 999px;
}

/* ---------------- category chips (fabric pills) ---------------- */
.chips { display: flex; flex-wrap: wrap; gap: 10px; margin: 14px 0 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px;
  background: rgba(255, 253, 248, .85);
  border: 1px solid rgba(139, 115, 85, .25);
  border-radius: 999px; cursor: pointer;
  font-size: 15px; font-family: inherit; color: var(--ink);
  transition: border-color .3s ease, background .3s ease, transform .3s ease, box-shadow .3s ease;
  user-select: none;
}
.chip:hover { border-color: var(--color-meadow); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(90, 143, 90, .20); }
.chip.active { background: var(--color-meadow); border-color: var(--color-meadow); color: var(--color-cloth); }

/* ---------------- item cards (linen card) ---------------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 18px; }
.card {
  background: linear-gradient(180deg, #fffdf8, #fcf6ec);
  border: 1px solid rgba(90, 143, 90, .16);
  border-radius: var(--radius-card);
  padding: 22px;
  box-shadow: 0 4px 10px rgba(90, 143, 90, .16);
  display: flex; flex-direction: column; gap: 12px;
  transition: transform .5s ease-in-out, box-shadow .5s ease-in-out;
}
.card:hover { transform: translateY(-4px) rotate(.6deg); box-shadow: 0 8px 20px rgba(90, 143, 90, .30); }
.card .card-top { display: flex; gap: 12px; align-items: flex-start; }

.icon-box {
  width: 52px; height: 52px; border-radius: 16px; flex: none;
  background: rgba(90, 143, 90, .12);
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
}
.icon-box img { width: 100%; height: 100%; object-fit: cover; border-radius: 16px; }

.card .title { font-size: 18px; font-weight: 600; margin: 0; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.35; }
.card .desc { font-size: 14px; line-height: 1.65; color: var(--muted); margin: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 46px; letter-spacing: .01em; }
.card .meta { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--muted); }
.card .actions { margin-top: auto; display: flex; gap: 10px; flex-wrap: wrap; }
.tag {
  background: rgba(90, 143, 90, .14); color: #3f6b3f;
  border-radius: 999px; padding: 2px 10px; font-size: 12px;
}

/* game card cover */
.cover-box {
  width: 100%; height: 150px; border-radius: 16px; overflow: hidden;
  background: #dfe3c8; position: relative; display: block;
}
.cover-box img { width: 100%; height: 100%; object-fit: cover; }
.cover-box .play-overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(61, 58, 52, .3);
  color: #fffdf8; font-size: 32px;
  opacity: 0; transition: opacity .4s ease;
}
.cover-box:hover .play-overlay, .cover-box:focus-visible .play-overlay { opacity: 1; }

/* ---------------- footer ---------------- */
.site-footer {
  margin-top: 60px;
  border-top: 2px dashed rgba(90, 143, 90, .28);
  padding: 26px 0;
  text-align: center;
  color: var(--muted); font-size: 14px;
}
.site-footer a { color: var(--muted); }

/* ---------------- empty / loading ---------------- */
.empty { text-align: center; color: var(--muted); padding: 40px 0; }
.spinner {
  width: 26px; height: 26px; margin: 20px auto;
  border: 3px solid rgba(90, 143, 90, .25); border-top-color: var(--color-meadow);
  border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- pagination ---------------- */
.pager { display: flex; justify-content: center; gap: 8px; margin-top: 24px; align-items: center; }
.pager button {
  min-width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid rgba(139, 115, 85, .25); background: #fffdf8;
  cursor: pointer; font-family: inherit; font-size: 14px; color: var(--ink);
  transition: transform .3s ease, box-shadow .3s ease;
}
.pager button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 4px 10px rgba(90, 143, 90, .20); }
.pager button.current { background: var(--color-meadow); color: var(--color-cloth); border-color: var(--color-meadow); }
.pager button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------------- toast ---------------- */
#toast-box { position: fixed; top: 76px; right: 18px; z-index: 999; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: #fffdf8; color: var(--ink);
  border: 1px solid rgba(90, 143, 90, .3);
  padding: 12px 18px; border-radius: 16px; font-size: 15px;
  box-shadow: var(--shadow-card); max-width: 340px;
}
.toast.ok { border-color: rgba(90, 143, 90, .45); }
.toast.err { border-color: rgba(212, 160, 160, .7); }

/* ---------------- modal ---------------- */
.modal-mask {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(61, 58, 52, .5);
  display: none; align-items: flex-start; justify-content: center;
  overflow: auto; padding: 60px 16px;
}
.modal-mask.show { display: flex; }
.modal {
  background: linear-gradient(180deg, #fffdf8, #fcf6ec);
  border: 1px solid rgba(90, 143, 90, .18);
  border-radius: 20px; width: 100%; max-width: 560px;
  padding: 28px; box-shadow: var(--shadow-card);
}
.modal.wide { max-width: 820px; }
.modal h3 { margin: 0 0 18px; }
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.form-row .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.input, .textarea, select.input {
  width: 100%; border: 1px solid rgba(139, 115, 85, .28); border-radius: var(--radius-input);
  padding: 10px 16px;
  font-size: 15px; font-family: inherit; background: #fffdf8; color: var(--ink); outline: none;
  transition: border-color .3s ease, box-shadow .3s ease;
}
.input:focus, .textarea:focus, select.input:focus {
  border-color: var(--color-meadow);
  box-shadow: 0 0 0 3px rgba(90, 143, 90, .15);
}
.textarea { min-height: 90px; resize: vertical; }
.modal .modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
.inline-errors { color: var(--bad); font-size: 13px; margin: 8px 0; }

/* ---------------- markdown article ---------------- */
.article {
  background: linear-gradient(180deg, #fffdf8, #fcf6ec);
  border: 1px solid rgba(90, 143, 90, .16);
  border-radius: var(--radius-card);
  padding: 32px;
  box-shadow: 0 4px 10px rgba(90, 143, 90, .16);
}
.article h1, .article h2 { border-bottom: 2px dashed rgba(90, 143, 90, .3); padding-bottom: 8px; }
.article pre {
  background: #2b3226; color: #f0ead8; padding: 16px; border-radius: 14px;
  overflow: auto; font-size: 13px;
}
.article code { background: rgba(90, 143, 90, .14); padding: 2px 6px; border-radius: 6px; font-size: 13px; }
.article pre code { background: none; padding: 0; }
.article table { border-collapse: collapse; margin: 12px 0; width: 100%; }
.article th, .article td { border: 1px solid rgba(139, 115, 85, .25); padding: 8px 14px; }
.article th { background: rgba(90, 143, 90, .10); }
.article blockquote {
  border-left: 3px solid var(--color-meadow);
  margin: 12px 0; padding: 4px 16px; color: var(--muted);
  background: rgba(90, 143, 90, .08);
}
.article img { max-width: 100%; }

/* ---------------- responsive ---------------- */
@media (max-width: 720px) {
  .site-header .container { gap: 10px; min-height: 56px; }
  .brand { font-size: 17px; }
  .nav { gap: 2px; margin-left: 0; }
  .nav a { padding: 6px 10px; font-size: 13px; }
  .search-bar { flex-direction: column; }
  .search-bar .btn { width: 100%; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
  .card { padding: 16px; }
  .pager button { min-width: 32px; height: 32px; }
  #toast-box { top: 64px; }
}

/* ---------------- reduced motion ---------------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .btn:hover, .btn:active, .card:hover, .chip:hover, .btn-outline:hover, .pager button:hover { transform: none; }
}
