/* Tibumo shared foundations for lightweight pages. */

@font-face {
  font-family: "TIBUMO-FONT";
  src: url("../fonts/TIBUMO-FONT.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0020-007E, U+00A0-00FF, U+0152-0153, U+0178, U+2018-2019, U+20AC, U+F000;
}

:root {
  --tibumo-blue: #4499f9;
  --tibumo-green: #69a623;
  --tibumo-orange: #eb7624;
  --tibumo-purple: #8335ce;
  --tibumo-yellow: #f5be32;
  --tibumo-pink: #ff69b4;
  --tibumo-skin: #f6e8da;
  --tibumo-purple-dark: #6c3ca0;
  --tibumo-black: #1a1a1a;
  --tibumo-cream: #f9f6f1;

  --primary: var(--tibumo-orange);
  --primary-light: var(--tibumo-skin);
  --primary-dark: var(--tibumo-orange);
  --bg: var(--tibumo-cream);
  --bg-warm: var(--tibumo-skin);
  --bg-cream: var(--tibumo-cream);
  --bg-subtle: color-mix(in srgb, var(--tibumo-cream) 76%, var(--tibumo-skin));
  --text: var(--tibumo-black);
  --text-secondary: rgba(26, 26, 26, 0.72);
  --text-tertiary: rgba(26, 26, 26, 0.52);
  --border: rgba(26, 26, 26, 0.14);
  --divider: rgba(26, 26, 26, 0.1);
  --radius-sm: 6px;
  --radius-md: 10px;
  --font: "Nunito", sans-serif;
  --brand-font: "TIBUMO-FONT", "Nunito", sans-serif;
  --display-font: "TIBUMO-FONT", "Nunito", sans-serif;
  --cjk-font: "Noto Sans SC", "Nunito", sans-serif;
}

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

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

body {
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

html[data-lang="zh"] body {
  font-family: var(--cjk-font);
}

a {
  color: inherit;
  text-decoration: none;
}

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

button {
  border: 0;
  background: none;
  cursor: pointer;
  font-family: inherit;
}

ul {
  list-style: none;
}

:focus-visible {
  border-radius: var(--radius-sm);
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.rainbow-title {
  max-width: 100%;
  white-space: normal;
}

.rainbow-title span {
  text-shadow: none;
}

.rainbow-title span:nth-child(5n + 1) { color: var(--tibumo-blue); }
.rainbow-title span:nth-child(5n + 2) { color: var(--tibumo-green); }
.rainbow-title span:nth-child(5n + 3) { color: var(--tibumo-orange); }
.rainbow-title span:nth-child(5n + 4) { color: var(--tibumo-purple); }
.rainbow-title span:nth-child(5n + 5) { color: var(--tibumo-pink); }

/* Shared download/open control. Collection styles only own placement and size. */
.resource-action {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 13px;
  border: 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 1px 3px rgba(26, 26, 26, 0.12), inset 0 -1px 0 rgba(26, 26, 26, 0.08);
  color: var(--tibumo-orange);
  cursor: pointer;
  font-family: var(--font);
  font-weight: 900;
  text-decoration: none;
  transform: none;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
  white-space: nowrap;
}

.resource-action:hover {
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 2px 6px rgba(26, 26, 26, 0.14), inset 0 -1px 0 rgba(26, 26, 26, 0.08);
  color: var(--tibumo-purple);
  transform: none;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: rgb(232, 214, 190);
  --bg-warm: rgb(244, 231, 213);
  --bg-cream: rgb(232, 214, 190);
  --bg-subtle: rgb(238, 222, 199);
  --text: #1a1a1a;
  --text-secondary: rgba(26, 26, 26, 0.72);
  --text-tertiary: rgba(26, 26, 26, 0.52);
  --border: rgb(213, 194, 169);
  --divider: rgb(224, 204, 178);
}

:root[data-theme="light"] body {
  background: var(--tibumo-cream);
  color: var(--text);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1a1a1a;
  --bg-warm: #1a1a1a;
  --bg-cream: #1a1a1a;
  --bg-subtle: #1a1a1a;
  --text: #f9f6f1;
  --text-secondary: #f6e8da;
  --text-tertiary: rgba(26, 26, 26, 0.52);
  --border: rgba(255, 255, 255, 0.18);
  --divider: rgba(255, 255, 255, 0.12);
}

:root[data-theme="dark"] body {
  background:
    radial-gradient(circle at 16% 8%, rgba(245, 190, 50, 0.12), transparent 26%),
    linear-gradient(180deg, #1a1a1a 0%, #1a1a1a 55%, #1a1a1a 100%);
  color: var(--text);
}

:root[data-theme="dark"] .rainbow-title span:nth-child(5n + 5) {
  color: var(--tibumo-yellow);
}

:root[data-theme="dark"] .resource-action {
  background: rgba(249, 246, 241, 0.1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.26), inset 0 -1px 0 rgba(249, 246, 241, 0.1);
  color: var(--tibumo-orange);
}

:root[data-theme="dark"] .resource-action:hover {
  background: rgba(249, 246, 241, 0.16);
  color: var(--tibumo-yellow);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #1a1a1a;
    --bg-warm: #1a1a1a;
    --bg-cream: #1a1a1a;
    --bg-subtle: #24263a;
    --text: #f9f6f1;
    --text-secondary: #f6e8da;
    --text-tertiary: rgba(249, 246, 241, 0.64);
    --border: rgba(255, 255, 255, 0.16);
    --divider: rgba(255, 255, 255, 0.12);
  }

  :root:not([data-theme="light"]) body {
    background:
      radial-gradient(circle at 16% 8%, rgba(245, 190, 50, 0.12), transparent 26%),
      linear-gradient(180deg, #1a1a1a 0%, #1a1a1a 55%, #1a1a1a 100%);
    color: var(--text);
  }

  :root:not([data-theme="light"]) .rainbow-title span:nth-child(5n + 5) {
    color: var(--tibumo-yellow);
  }

  :root:not([data-theme="light"]) .resource-action {
    background: rgba(249, 246, 241, 0.1);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.26), inset 0 -1px 0 rgba(249, 246, 241, 0.1);
    color: var(--tibumo-orange);
  }

  :root:not([data-theme="light"]) .resource-action:hover {
    background: rgba(249, 246, 241, 0.16);
    color: var(--tibumo-yellow);
  }
}
