/* Design tokens and shared components used by both the directory and admin. */

:root {
  color-scheme: light;

  /* Brand palette, taken from the company logo (China flag red and yellow) */
  --brand-red: #df280f;
  --brand-red-deep: #c21f0a;
  --brand-yellow: #ffdf00;
  --brand-tint: #fdeceb;
  /* Taobao-style orange gradient (footer band) */
  --taobao-gradient: linear-gradient(90deg, #ff9000 0%, #ff5000 100%);

  --ink: 28 25 23; /* rgb channels for shadows and overlays */
  --bg: #faf7f5;
  --surface: #ffffff;
  --surface-muted: #f3eeea;
  --border: #e8e1db;
  --border-strong: #d4cac2;
  --text: #1c1917;
  --text-muted: #57534e;
  --text-subtle: #6b625c;

  --accent: var(--brand-red);
  --accent-hover: var(--brand-red-deep);
  --accent-soft: var(--brand-tint);
  --accent-text: var(--brand-red-deep);

  --danger: #a3392a;
  --danger-hover: #87291c;
  --danger-soft: #f8e9e5;
  --success-soft: #fdeceb;
  --warning-soft: #f5ecd9;
  --warning-text: #6b4e12;

  --font-sans: ui-sans-serif, -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Helvetica Neue', Arial, sans-serif;
  --font-serif: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgb(var(--ink) / 0.05);
  --shadow: 0 1px 2px rgb(var(--ink) / 0.05), 0 4px 14px rgb(var(--ink) / 0.06);
  --shadow-lg: 0 10px 40px rgb(var(--ink) / 0.18);

  --page-max: 1160px;
  --gutter: clamp(16px, 4vw, 32px);
  --focus: 0 0 0 3px rgb(223 40 15 / 0.4);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: var(--accent-text);
  text-underline-offset: 3px;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.2;
  font-weight: 600;
}

p {
  margin: 0;
}

button,
input,
textarea,
select {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.container {
  width: 100%;
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 0 var(--gutter);
}

.skip-link {
  position: absolute;
  left: 12px;
  top: -48px;
  z-index: 100;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: #fff;
  text-decoration: none;
}

.skip-link:focus {
  top: 12px;
}

/* ---- Brand --------------------------------------------------------------- */

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  letter-spacing: -0.01em;
}

.brand-logo {
  flex: none;
  width: 32px;
  height: 32px;
}

.brand-name {
  font-size: 17px;
}

.brand-suffix {
  color: var(--text-subtle);
  font-weight: 450;
}

/* ---- Buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: none;
  font-size: 15px;
  font-weight: 550;
  line-height: 1;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn-secondary {
  border-color: var(--border-strong);
  background: var(--surface);
  color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--text-subtle);
}

.btn-ghost {
  color: var(--text-muted);
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface-muted);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
}

.btn-sm {
  min-height: 34px;
  padding: 0 12px;
  font-size: 14px;
}

/* ---- Tags ---------------------------------------------------------------- */

.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.tag {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 13px;
  line-height: 1.4;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.5;
  white-space: nowrap;
}

.badge-sample {
  background: var(--warning-soft);
  color: var(--warning-text);
}

/* ---- Logo / monogram ----------------------------------------------------- */

.logo-tile {
  flex: none;
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--accent-text);
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.logo-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #fff;
}

/* ---- Form controls ------------------------------------------------------- */

.input {
  width: 100%;
  min-height: 42px;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: var(--text-subtle);
}

.input:hover {
  border-color: var(--text-subtle);
}

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.input[aria-invalid='true'] {
  border-color: var(--danger);
}

textarea.input {
  min-height: 108px;
  resize: vertical;
}

/* ---- Alerts & status ----------------------------------------------------- */

.alert {
  padding: 11px 14px;
  border: 1px solid;
  border-radius: var(--radius-sm);
  font-size: 14px;
}

.alert-error {
  border-color: #e7c3bb;
  background: var(--danger-soft);
  color: #7d2a1e;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

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

/* Off-screen textarea used by the clipboard fallback. */
.copy-buffer {
  position: fixed;
  top: 0;
  left: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

/* ---- Platform badge ------------------------------------------------------ */

.platform {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 550;
  line-height: 20px;
  white-space: nowrap;
}

.platform-logo {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  object-fit: cover;
  box-shadow: 0 0 0 1px rgb(var(--ink) / 0.08);
}

.platform-logo-fallback {
  display: grid;
  place-items: center;
  background: var(--surface-muted);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
}
