/* ==========================================================================
   BASE.CSS — design tokens + document defaults
   Load order (base.html): base → components → navigation → footer → legal
   → page stylesheet. Pages override tokens on their wrapper, never on :root.

   Light and dark follow the visitor's system setting (prefers-color-scheme).
   Dark mode only redefines tokens (bottom of the :root block), so a page that
   uses tokens instead of hard-coded colours gets dark mode for free.
   ========================================================================== */

:root {
  /* List bullet: lobes 1 & 5 of the PP Cycle feng huo lun (icons.html #icon-pp-bullet).
     Used as a mask so it takes the bullet colour in light and dark mode. */
  --pp-bullet: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='-10 -10 20 20' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M0,-1.5C0,-10 5.2,-11.2 5.2,-8.4C5.2,-6.8 3.5,-6.2 2.2,-7' transform='rotate%2822.5%29'/%3E%3Cpath d='M0,-1.5C0,-10 5.2,-11.2 5.2,-8.4C5.2,-6.8 3.5,-6.2 2.2,-7' transform='rotate%28202.5%29'/%3E%3C/svg%3E");
  /* The site styles both schemes itself, so browsers don't force-darken it */
  color-scheme: light dark;

  /* --- Ink & paper (宣纸) ------------------------------------------------ */
  --ink-paper-bg: #f8f0e3;
  --ink-card-bg: rgba(255, 255, 255, 0.94);
  --ink-card-solid: #ffffff;         /* opaque card / chip surface */
  --page-bg: #f4ede0;                /* paper tone under the painting */
  --page-wash: transparent;          /* veil over the painting (dark mode dims it) */
  --ink-dark: #232220;               /* pine soot ink (松烟墨) */
  --ink-muted: #5e554d;
  --ink-body: #4f473f;               /* long-form reading text */
  --ink-mountain-wash: #8c8273;      /* mountain mist (远山黛) */
  --ink-soft: #8a7f73;

  /* --- Gold (泥金) ------------------------------------------------------- */
  --ink-gold: #b3882f;
  --ink-gold-hover: #966e1e;
  --ink-gold-bright: #d4a742;
  --ink-gold-light: rgba(179, 136, 47, 0.12);
  --ink-gold-glow: rgba(179, 136, 47, 0.18);
  --ink-gold-deep: #8a6420;          /* gold text on pale gold chips */

  /* --- Reds -------------------------------------------------------------- */
  --ink-cinnabar: #a83226;
  --ink-cinnabar-glow: rgba(168, 50, 38, 0.16);
  --ink-accent-red: #c92a2a;         /* 朱砂红 */
  --ink-accent-red-light: rgba(201, 42, 42, 0.1);
  --ink-peach-pink: #d9485e;
  --ink-red-deep: #871f15;
  --ink-jade: #00876c;               /* positive / success text */

  /* --- Lines ------------------------------------------------------------- */
  --ink-border-wash: rgba(179, 136, 47, 0.22);
  --ink-border-gold: rgba(179, 136, 47, 0.35);
  --ink-border-light: rgba(120, 100, 75, 0.15);

  /* --- Shadows ----------------------------------------------------------- */
  --ink-shadow-sm: 0 4px 16px rgba(40, 30, 20, 0.05);
  --ink-shadow-md: 0 10px 30px rgba(40, 30, 20, 0.08);
  --ink-shadow-lg: 0 20px 45px rgba(40, 30, 20, 0.12);
  --panel-shadow: 0 16px 40px rgba(179, 136, 47, 0.15), 0 6px 16px rgba(0, 0, 0, 0.06);

  /* --- Glass surfaces (the background painting shows through) -----------
     Lower alpha = more see-through. Pages may retune these on their wrapper. */
  --tint-white: 255 255 255;         /* rgb channels: rgb(var(--tint-white) / 0.5) */
  --tint-paper: 255 252 245;
  --glass-outer: rgb(var(--tint-paper) / 0.22);
  --glass-section: rgb(var(--tint-white) / 0.34);
  --glass-input: rgb(var(--tint-white) / 0.6);
  --glass-input-focus: rgb(var(--tint-white) / 0.88);
  --glass-blur: blur(1.5px);

  /* --- Type -------------------------------------------------------------- */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-zh: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;

  /* --- Header ------------------------------------------------------------ */
  --ink-header-bg: rgba(248, 240, 227, 0.86);
  --ink-menu-bg: rgba(255, 252, 245, 0.98);
  --ink-menu-solid: #fffcf5;         /* opaque sheet on phones */
  --ink-header-h: 64px;              /* updated by header.html script */
  --font-nav-label: clamp(10px, 0.4vw + 8.5px, 12px);
}

/* --- Dark scheme: midnight silk & gold ink --------------------------------
   Gold stays the same hue (white-on-gold buttons keep their contrast);
   ink, paper, glass and lines flip. */
@media (prefers-color-scheme: dark) {
  :root {
    --ink-paper-bg: #1a1916;
    --ink-card-bg: rgba(32, 30, 27, 0.94);
    --ink-card-solid: #24221e;
    --page-bg: #141311;
    --page-wash: rgba(16, 15, 13, 0.78);
    --ink-dark: #ece6da;
    --ink-muted: #c9c1b3;
    --ink-body: #d2cabb;
    --ink-mountain-wash: #a39a8b;
    --ink-soft: #a8a092;

    --ink-gold-bright: #e5cb8f;
    --ink-gold-light: rgba(201, 154, 60, 0.16);
    --ink-gold-glow: rgba(201, 154, 60, 0.22);
    --ink-gold-deep: #e0b864;

    --ink-cinnabar: #e0705f;
    --ink-cinnabar-glow: rgba(224, 112, 95, 0.18);
    --ink-accent-red: #e5534b;
    --ink-accent-red-light: rgba(229, 83, 75, 0.14);
    --ink-peach-pink: #ec6f83;
    --ink-red-deep: #ef8a7a;
    --ink-jade: #3cc19f;

    --ink-border-wash: rgba(214, 172, 92, 0.24);
    --ink-border-gold: rgba(214, 172, 92, 0.42);
    --ink-border-light: rgba(255, 240, 210, 0.1);

    --ink-shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.3);
    --ink-shadow-md: 0 10px 30px rgba(0, 0, 0, 0.4);
    --ink-shadow-lg: 0 20px 45px rgba(0, 0, 0, 0.5);
    --panel-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 6px 16px rgba(0, 0, 0, 0.3);

    --tint-white: 44 41 36;
    --tint-paper: 34 32 28;
    --glass-outer: rgb(var(--tint-paper) / 0.5);
    --glass-section: rgb(var(--tint-white) / 0.45);
    --glass-input: rgb(var(--tint-white) / 0.65);
    --glass-input-focus: rgb(var(--tint-white) / 0.9);

    --ink-header-bg: rgba(26, 25, 22, 0.86);
    --ink-menu-bg: rgba(30, 28, 25, 0.98);
    --ink-menu-solid: #1e1c19;
  }
}

html,
body {
  min-height: 100%;
  margin: 0;
  padding: 0;
  font-family: var(--font-sans);
  overflow-x: clip;                  /* never scroll sideways */
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--page-bg);  /* paper tone if the painting hasn't loaded */
  background-image: linear-gradient(var(--page-wash), var(--page-wash)), url('../images/02.png');
  background-repeat: no-repeat;
  background-position: center top;
  background-size: cover;
  background-attachment: fixed;
}

main {
  flex: 1 0 auto;
  overflow-y: auto;
}

h1 {
  font-size: clamp(1.2rem, 5vw, 1.8rem);
}

/* Flash messages (partials/messages.html) */
.flash {
  padding: 12px;
  color: #000;          /* light flash colours in both schemes */
  margin-bottom: 10px;
}

.flash.danger  { background: #ffdede; }
.flash.success { background: #ddffdd; }

/* ==========================================================================
   LANGUAGE — master switch (base.html sets <html data-lang="en|zh">)
   Shared markup: .i18n-en / .i18n-zh. Pages may keep their own class names
   (lang-en, pl-en, bc-en, pp-en…) keyed off html[data-lang] the same way.
   ========================================================================== */
html[data-lang="en"] .i18n-zh,
html[data-lang="zh"] .i18n-en {
  display: none !important;
}

.i18n-zh {
  font-family: var(--font-zh);
}
