/*
 * WLT unified visual foundation
 * Direction: Quiet Editorial / warm paper x red proof
 *
 * This file is the only cross-surface source for color, type, geometry,
 * material, interaction and the Casdoor login adapter. Surface-local CSS may
 * arrange product content, but it must consume these tokens rather than invent
 * another palette.
 */

:root {
  color-scheme: light;

  /* Warm paper neutral scale. */
  --wlt-paper-0: #ffffff;
  --wlt-paper-25: #fcfbf8;
  --wlt-paper-50: #f7f5ef;
  --wlt-paper-100: #f1eee7;
  --wlt-paper-200: #e6e1d8;
  --wlt-paper-300: #d8d1c6;
  --wlt-paper-400: #b9b1a4;
  --wlt-paper-500: #938b7e;
  --wlt-paper-600: #6e675d;
  --wlt-paper-700: #4f4a43;
  --wlt-paper-800: #37332e;
  --wlt-paper-900: #24211e;

  /* Red proof scale. Bright red is a mark; darker red carries actions/text. */
  --wlt-red-50: #fff2f0;
  --wlt-red-100: #ffded9;
  --wlt-red-200: #ffb8b0;
  --wlt-red-300: #ff8277;
  --wlt-red-400: #ff5247;
  --wlt-red-500: #ff3333;
  --wlt-red-600: #d42b2b;
  --wlt-red-700: #b42323;
  --wlt-red-800: #8d1d1d;
  --wlt-red-900: #651919;

  /* Semantic aliases: these are the values product code should consume. */
  --wlt-color-canvas: var(--wlt-paper-50);
  --wlt-color-surface: var(--wlt-paper-25);
  --wlt-color-surface-raised: var(--wlt-paper-0);
  --wlt-color-surface-inset: var(--wlt-paper-100);
  --wlt-color-text-strong: var(--wlt-paper-900);
  --wlt-color-text: var(--wlt-paper-700);
  --wlt-color-text-muted: var(--wlt-paper-600);
  --wlt-color-text-decorative: var(--wlt-paper-500);
  --wlt-color-line-subtle: var(--wlt-paper-200);
  --wlt-color-line: var(--wlt-paper-300);
  --wlt-color-border-control: var(--wlt-paper-500);
  --wlt-color-brand-mark: var(--wlt-red-500);
  --wlt-color-proof-line: var(--wlt-red-200);
  --wlt-color-action: var(--wlt-red-600);
  --wlt-color-action-hover: var(--wlt-red-700);
  --wlt-color-action-active: var(--wlt-red-800);
  --wlt-color-action-soft: var(--wlt-red-50);
  --wlt-color-focus: var(--wlt-red-600);

  /* Status colors are independent from the brand mark. */
  --wlt-color-danger: #a13d32;
  --wlt-color-danger-surface: #faece9;
  --wlt-color-success: #2f6d50;
  --wlt-color-success-surface: #e9f2ed;
  --wlt-color-warning: #7a5a13;
  --wlt-color-warning-surface: #f6f0de;
  --wlt-color-info: #315f7d;
  --wlt-color-info-surface: #e9f1f5;
  --wlt-color-overlay: rgba(36, 33, 30, 0.42);

  /* Restrained code palette, derived only from registered semantic roles. */
  --wlt-color-syntax-base: var(--wlt-color-text);
  --wlt-color-syntax-muted: var(--wlt-color-text-muted);
  --wlt-color-syntax-keyword: var(--wlt-color-action-hover);
  --wlt-color-syntax-function: var(--wlt-color-info);
  --wlt-color-syntax-literal: var(--wlt-color-warning);
  --wlt-color-syntax-symbol: var(--wlt-color-success);

  --wlt-font-display: "Roboto", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
  --wlt-font-ui: "Montserrat", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  --wlt-font-mono: "Roboto Mono", "SFMono-Regular", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;

  --wlt-space-1: 6px;
  --wlt-space-2: 12px;
  --wlt-space-3: 18px;
  --wlt-space-4: 24px;
  --wlt-space-6: 36px;
  --wlt-space-9: 54px;

  --wlt-radius-compact: 2px;
  --wlt-radius-subtle: 4px;
  --wlt-radius-control: 8px;
  --wlt-radius-panel: 12px;
  --wlt-radius-feature: 18px;
  --wlt-radius-pill: 999px;

  --wlt-shadow-overlay: 0 1px 2px rgba(36, 33, 30, 0.05),
    0 16px 40px rgba(36, 33, 30, 0.08);
  --wlt-motion-fast: 160ms ease;
  --wlt-motion-standard: 240ms ease;

  --wlt-width-reading: min(750px, calc(100vw - 60px));
  --wlt-width-product: min(1080px, calc(100vw - 40px));
  --wlt-width-login: min(560px, calc(100vw - 40px));

  --wlt-paper-texture: url("/assets/textures/paper-fiber-v1.jpg");
  --wlt-paper-texture-size: 512px 512px;
  --wlt-paper-texture-opacity: 0.14;
}

/* Surface foundation is opt-in so this file cannot pollute upstream DOMs. */
[data-wlt-surface] {
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  isolation: isolate;
  background-color: var(--wlt-color-canvas);
  color: var(--wlt-color-text);
  font-family: var(--wlt-font-ui);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

[data-wlt-surface="editorial"] {
  --wlt-paper-texture-opacity: 0.22;
  font-family: var(--wlt-font-display);
}

[data-wlt-surface="product"] {
  --wlt-paper-texture-opacity: 0.12;
}

[data-wlt-surface="utility"] {
  --wlt-paper-texture-opacity: 0.16;
}

[data-wlt-paper="textured"]::before,
.wlt-paper-field::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: var(--wlt-paper-texture);
  background-repeat: repeat;
  background-size: var(--wlt-paper-texture-size);
  opacity: var(--wlt-paper-texture-opacity);
}

[data-wlt-surface] :where(a, button, input, select, textarea):focus-visible,
.wlt-focus-ring:focus-visible {
  outline: 2px solid var(--wlt-color-focus);
  outline-offset: 3px;
}

/* Author-level display rules must never override the HTML hidden contract. */
[data-wlt-surface] [hidden] {
  display: none !important;
}

.wlt-paper-field {
  position: relative;
  isolation: isolate;
  background-color: var(--wlt-color-canvas);
}

.wlt-panel {
  border: 1px solid var(--wlt-color-line-subtle);
  border-radius: var(--wlt-radius-panel);
  background: var(--wlt-color-surface);
  color: var(--wlt-color-text);
}

.wlt-panel--raised {
  border-color: var(--wlt-color-line);
  background: var(--wlt-color-surface-raised);
}

.wlt-overlay {
  box-shadow: var(--wlt-shadow-overlay);
}

.wlt-meta {
  color: var(--wlt-color-text-muted);
  font-family: var(--wlt-font-ui);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.wlt-rule {
  height: 1px;
  border: 0;
  background: var(--wlt-color-line-subtle);
}

.wlt-proof-mark {
  color: var(--wlt-color-brand-mark);
}

.wlt-button {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--wlt-space-3);
  border: 1px solid var(--wlt-color-border-control);
  border-radius: var(--wlt-radius-pill);
  background: var(--wlt-color-surface);
  color: var(--wlt-color-text-strong);
  cursor: pointer;
  font: inherit;
  text-decoration: none;
  transition: background-color var(--wlt-motion-fast),
    border-color var(--wlt-motion-fast), color var(--wlt-motion-fast);
}

.wlt-button:not(:disabled):not([aria-disabled="true"]):hover {
  background: var(--wlt-color-surface-inset);
}

.wlt-button--text {
  min-height: 32px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--wlt-color-text-muted);
}

.wlt-button--text:not(:disabled):not([aria-disabled="true"]):hover {
  background: transparent;
  color: var(--wlt-color-action);
}

.wlt-button--primary {
  border-color: var(--wlt-color-action);
  background: var(--wlt-color-action);
  color: var(--wlt-paper-0);
}

.wlt-button--primary:not(:disabled):not([aria-disabled="true"]):hover {
  border-color: var(--wlt-color-action-hover);
  background: var(--wlt-color-action-hover);
}

.wlt-button--primary:not(:disabled):not([aria-disabled="true"]):active {
  border-color: var(--wlt-color-action-active);
  background: var(--wlt-color-action-active);
}

.wlt-button--danger {
  border-color: var(--wlt-color-danger);
  background: var(--wlt-color-danger-surface);
  color: var(--wlt-color-danger);
}

.wlt-button--danger:not(:disabled):not([aria-disabled="true"]):hover {
  border-color: var(--wlt-color-danger);
  background: var(--wlt-color-danger);
  color: var(--wlt-paper-0);
}

.wlt-button:disabled,
.wlt-button[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.58;
}

.wlt-field {
  min-height: 44px;
  border: 1px solid var(--wlt-color-border-control);
  border-radius: var(--wlt-radius-control);
  background: var(--wlt-color-surface-raised);
  color: var(--wlt-color-text-strong);
  font: inherit;
}

.wlt-field:disabled,
.wlt-field[aria-disabled="true"] {
  cursor: not-allowed;
  border-color: var(--wlt-color-line);
  background: var(--wlt-color-surface-inset);
  color: var(--wlt-color-text-muted);
  opacity: 0.72;
}

.wlt-field[aria-invalid="true"] {
  border-color: var(--wlt-color-danger);
}

.wlt-check {
  width: 18px;
  height: 18px;
  accent-color: var(--wlt-color-action);
}

.wlt-check:disabled,
.wlt-check[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.58;
}

/* Non-pill interaction families share behavior without sharing button shape. */
.wlt-disclosure {
  border: 0;
  background: transparent;
  color: var(--wlt-color-text-strong);
  cursor: pointer;
  font: inherit;
}

.wlt-tab {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--wlt-color-text-muted);
  cursor: pointer;
  font-family: var(--wlt-font-ui);
  transition: border-color var(--wlt-motion-fast), color var(--wlt-motion-fast);
}

.wlt-tab:not(:disabled):not([aria-disabled="true"]):hover,
.wlt-tab.is-active,
.wlt-tab[aria-selected="true"] {
  border-bottom-color: var(--wlt-color-brand-mark);
  color: var(--wlt-color-text-strong);
}

.wlt-list-action {
  border: 1px solid transparent;
  border-radius: var(--wlt-radius-control);
  background: transparent;
  color: var(--wlt-color-text);
  cursor: pointer;
  font: inherit;
  transition: background-color var(--wlt-motion-fast),
    border-color var(--wlt-motion-fast), color var(--wlt-motion-fast);
}

.wlt-list-action:not(:disabled):not([aria-disabled="true"]):hover {
  border-color: var(--wlt-color-proof-line);
  background: var(--wlt-color-action-soft);
}

.wlt-list-action.is-active,
.wlt-list-action[aria-current="true"] {
  border-color: var(--wlt-color-action);
  background: var(--wlt-color-action-soft);
}

.wlt-disclosure:disabled,
.wlt-disclosure[aria-disabled="true"],
.wlt-tab:disabled,
.wlt-tab[aria-disabled="true"],
.wlt-list-action:disabled,
.wlt-list-action[aria-disabled="true"] {
  cursor: not-allowed;
  opacity: 0.58;
}

.wlt-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 var(--wlt-space-2);
  border: 1px solid var(--wlt-color-line);
  border-radius: var(--wlt-radius-pill);
  background: var(--wlt-color-surface-inset);
  color: var(--wlt-color-text);
  font-family: var(--wlt-font-mono);
  font-size: 0.75rem;
}

.wlt-media-frame {
  margin: 0;
  padding: var(--wlt-space-1);
  border: 1px solid var(--wlt-color-line);
  border-radius: var(--wlt-radius-control);
  background: var(--wlt-color-surface);
}

.wlt-media-frame > :where(img, picture, video),
.wlt-media-frame picture > img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: var(--wlt-radius-compact);
}

.wlt-media-caption {
  margin: var(--wlt-space-1) var(--wlt-space-1) 0;
  color: var(--wlt-color-text-muted);
  font-family: var(--wlt-font-mono);
  font-size: 0.75rem;
  line-height: 1.5;
}

/* WLT_CASDOOR_BEGIN */
.loginBackground {
  --wlt-login-canvas: #f7f5ef;
  --wlt-login-surface: #fcfbf8;
  --wlt-login-raised: #ffffff;
  --wlt-login-ink: #4f4a43;
  --wlt-login-ink-strong: #24211e;
  --wlt-login-muted: #6e675d;
  --wlt-login-line: #d8d1c6;
  --wlt-login-control: #938b7e;
  --wlt-login-action: #d42b2b;
  --wlt-login-action-hover: #b42323;
  --wlt-login-action-active: #8d1d1d;
  --wlt-login-danger: #a13d32;
  background: var(--wlt-login-canvas) !important;
  color: var(--wlt-login-ink) !important;
  font-family: "Roboto", "Noto Serif CJK SC", "Source Han Serif SC", "Songti SC", Georgia, serif !important;
  min-height: 100vh;
  min-height: 100dvh;
}

.loginBackground .login-logo-box,
.loginBackground .select-box,
.loginBackground .login-languages,
.loginBackground .side-image {
  display: none !important;
}

.loginBackground .login-content {
  box-sizing: border-box;
  margin: 0 auto !important;
  padding: 54px 20px;
  width: min(560px, 100%);
}

.loginBackground .login-panel {
  width: 100%;
  margin: 0 !important;
  overflow: hidden;
  border: 1px solid var(--wlt-login-line);
  border-radius: 18px;
  background: var(--wlt-login-surface) !important;
  box-shadow: none;
}

.loginBackground .login-form {
  box-sizing: border-box;
  width: 100%;
  padding: 36px;
  color: var(--wlt-login-ink);
  text-align: left;
}

.loginBackground .login-form *,
.loginBackground .ant-form,
.loginBackground .ant-tabs {
  box-sizing: border-box;
}

.loginBackground .ant-tabs-tab,
.loginBackground .ant-btn,
.loginBackground .ant-input,
.loginBackground .ant-input-affix-wrapper {
  font-family: "Montserrat", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", "Microsoft YaHei", sans-serif !important;
}

.loginBackground .ant-tabs-tab.ant-tabs-tab-active .ant-tabs-tab-btn,
.loginBackground a {
  color: var(--wlt-login-action) !important;
}

.loginBackground .ant-tabs-ink-bar,
.loginBackground .ant-checkbox-checked .ant-checkbox-inner {
  border-color: var(--wlt-login-action) !important;
  background: var(--wlt-login-action) !important;
}

.loginBackground .ant-input,
.loginBackground .ant-input-affix-wrapper {
  min-height: 44px;
  border-color: var(--wlt-login-control) !important;
  border-radius: 999px !important;
  background: var(--wlt-login-raised) !important;
  color: var(--wlt-login-ink-strong) !important;
  transition: border-color 160ms ease, outline-color 160ms ease;
}

.loginBackground .ant-input-affix-wrapper .ant-input {
  min-height: auto;
}

.loginBackground .ant-input:hover,
.loginBackground .ant-input:focus,
.loginBackground .ant-input-affix-wrapper:hover,
.loginBackground .ant-input-affix-wrapper-focused {
  border-color: var(--wlt-login-action) !important;
}

.loginBackground .ant-input:focus,
.loginBackground .ant-input-affix-wrapper-focused,
.loginBackground .ant-btn:focus-visible,
.loginBackground a:focus-visible {
  outline: 2px solid var(--wlt-login-action) !important;
  outline-offset: 3px;
  box-shadow: none !important;
}

.loginBackground .ant-btn-primary {
  min-height: 44px;
  border-color: var(--wlt-login-action) !important;
  border-radius: 999px !important;
  background: var(--wlt-login-action) !important;
  box-shadow: none !important;
  color: var(--wlt-login-raised) !important;
  transition: background 160ms ease, border-color 160ms ease;
}

.loginBackground .ant-btn-primary:hover,
.loginBackground .ant-btn-primary:focus {
  border-color: var(--wlt-login-action-hover) !important;
  background: var(--wlt-login-action-hover) !important;
}

.loginBackground .ant-btn-primary:active {
  border-color: var(--wlt-login-action-active) !important;
  background: var(--wlt-login-action-active) !important;
}

.loginBackground .ant-form-item-explain-error {
  color: var(--wlt-login-danger) !important;
}

@media (max-width: 500px) {
  .loginBackground .login-content {
    padding: 24px 20px;
  }

  .loginBackground .login-form {
    padding: 24px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .loginBackground *,
  .loginBackground *::before,
  .loginBackground *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
/* WLT_CASDOOR_END */

@media (max-width: 780px) {
  :root {
    --wlt-width-reading: min(100% - 40px, 750px);
    --wlt-width-product: min(100% - 28px, 1080px);
  }
}

@media (max-width: 500px) {
  :root {
    --wlt-width-reading: min(100% - 28px, 750px);
  }
}

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

@media (forced-colors: active), print {
  [data-wlt-paper="textured"]::before,
  .wlt-paper-field::before {
    display: none;
  }
}
