/* ==========================================================================
   Technoblade Wiki — style.css
   Design tokens, base styles and shared components.
   Light mode is the default. Dark mode is enabled via [data-theme="dark"]
   on the <html> element (toggled by js/main.js, persisted in localStorage).
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Design tokens
   -------------------------------------------------------------------------- */
:root {
  /* Color — light theme (default) */
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-bg-subtle: #f6f7f8;
  --color-bg-muted: #eceef0;
  --color-text: #1f2428;
  --color-heading: #171a1d;
  --color-text-muted: #5a6169;
  --color-border: #dde1e5;
  --color-border-strong: #c3c9cf;
  --color-accent: #9e2b25;
  --color-accent-strong: #7c211c;
  --color-accent-soft: #f8efee;
  --color-accent-border: #dcb2af;
  --color-link: #9e2b25;
  --color-link-strong: #7c211c;
  --color-code-bg: #f2f3f5;

  /* Typography */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --text-xs: 0.75rem;
  --text-sm: 0.875rem;
  --text-base: 1rem;
  --text-md: 1.0625rem;
  --text-lg: 1.1875rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.625rem;
  --text-3xl: 2rem;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.5rem;
  --space-6: 2rem;
  --space-7: 3rem;
  --space-8: 4rem;

  /* Shape & depth (minimal shadows only) */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 10px;
  --shadow-sm: 0 1px 3px rgba(23, 26, 29, 0.08);
  --shadow-md: 0 4px 14px rgba(23, 26, 29, 0.1);

  /* Layout */
  --header-height: 60px;
  --sidebar-width: 250px;
  --content-max: 1240px;
  --reading-width: 820px;

  color-scheme: light;
}

/* Color — dark theme */
[data-theme="dark"] {
  --color-bg: #15181c;
  --color-surface: #1a1e23;
  --color-bg-subtle: #1d2228;
  --color-bg-muted: #262c33;
  --color-text: #d5d8db;
  --color-heading: #eceef0;
  --color-text-muted: #9aa1a9;
  --color-border: #2b3138;
  --color-border-strong: #3d444c;
  --color-accent: #cf4d47;
  --color-accent-strong: #e0605a;
  --color-accent-soft: #2a1d1c;
  --color-accent-border: #4a2c2a;
  --color-link: #e0857f;
  --color-link-strong: #eb9a95;
  --color-code-bg: #22272d;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.45);

  color-scheme: dark;
}

/* --------------------------------------------------------------------------
   2. Reset & base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  /* Keep anchored headings clear of the sticky header */
  scroll-padding-top: calc(var(--header-height) + 16px);
}

/* Mobile header is two rows tall, so anchors need more clearance */
@media (max-width: 767px) {
  html {
    scroll-padding-top: 128px;
  }
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.65;
  color: var(--color-text);
  background-color: var(--color-bg);
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

img,
svg,
video {
  display: block;
  max-width: 100%;
  height: auto;
}

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

button {
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--color-heading);
  line-height: 1.25;
  font-weight: 600;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

p {
  margin-block: 0;
}

a {
  color: var(--color-link);
  text-decoration: none;
}

a:hover {
  color: var(--color-link-strong);
  text-decoration: underline;
  text-underline-offset: 2px;
}

ul[class],
ol[class] {
  padding: 0;
  list-style: none;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.92em;
  background-color: var(--color-code-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.1em 0.35em;
}

:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
  border-radius: 2px;
}

::selection {
  background-color: rgba(158, 43, 37, 0.22);
}

/* Thin, unobtrusive scrollbars for scrollable regions */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border-strong) transparent;
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-thumb {
  background-color: var(--color-border-strong);
  border-radius: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* --------------------------------------------------------------------------
   3. Layout primitives
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--content-max);
  margin-inline: auto;
  padding-inline: clamp(1rem, 4vw, 1.5rem);
}

/* Main content area grows so the footer stays pinned to the bottom
   on short pages and is pushed down naturally on long pages. */
main {
  flex: 1 0 auto;
}

/* --------------------------------------------------------------------------
   4. Utility & accessibility helpers
   -------------------------------------------------------------------------- */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -48px;
  left: 1rem;
  z-index: 200;
  padding: 0.625rem 1rem;
  background-color: var(--color-accent);
  color: #ffffff;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  font-size: var(--text-sm);
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0;
  color: #ffffff;
}

/* --------------------------------------------------------------------------
   5. Shared components
   -------------------------------------------------------------------------- */

/* Notice box — used for fan-project notices and reference notes */
.notice-box {
  background-color: var(--color-accent-soft);
  border: 1px solid var(--color-accent-border);
  border-left: 4px solid var(--color-accent);
  border-radius: var(--radius-md);
  padding: var(--space-4) var(--space-5);
  font-size: var(--text-sm);
  color: var(--color-text);
}

.notice-box .notice-title {
  display: block;
  font-weight: 600;
  color: var(--color-heading);
  margin-bottom: var(--space-1);
}

/* Card — base surface for grids and teasers */
.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-sm);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: var(--space-4);
}

.card-title {
  font-size: var(--text-md);
  margin-bottom: var(--space-2);
}

.card-title a {
  color: var(--color-heading);
}

.card-title a:hover {
  color: var(--color-link);
}

.card-text {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-bottom: var(--space-3);
}

.card-meta {
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  border-top: 1px solid var(--color-border);
  padding-top: var(--space-3);
}

/* Category tag pills */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.tag {
  display: inline-block;
  padding: 0.2rem 0.7rem;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-accent);
  background-color: var(--color-accent-soft);
  border: 1px solid var(--color-accent-border);
  border-radius: 999px;
  transition: background-color 0.15s ease;
}

.tag:hover {
  background-color: var(--color-bg-muted);
  text-decoration: none;
}

/* Homepage section headers */
.section-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  border-bottom: 2px solid var(--color-border);
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-5);
}

.section-header h2 {
  font-size: var(--text-xl);
}

.section-header .section-link {
  font-size: var(--text-sm);
  white-space: nowrap;
}

/* Small red kicker label above section titles */
.section-kicker {
  display: inline-block;
  font-size: var(--text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-accent);
  margin-bottom: var(--space-2);
}

/* --------------------------------------------------------------------------
   6. Motion preferences
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}
