/* ===== Theme Variables ===== */
:root {
  color-scheme: light dark;
  --bg: #fefce8;
  --surface: #ffffff;
  --surface-2: #f5f5f4;
  --text: #1c1917;
  --muted: #78716c;
  --border: #e7e5e4;
  --primary: #d97706;
  --primary-hover: #b45309;
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  --tag-bg: #fef3c7;
  --tag-text: #92400e;
  --code-bg: #1c1917;
  --code-text: #fafaf9;
  --success: #16a34a;
  --warning: #d97706;
  --shadow: 0 18px 40px rgba(28, 25, 23, .06);
  --header-bg: linear-gradient(135deg, #fef3c7 0%, #fefce8 40%, #fffbeb 100%);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #1c1917;
  --surface: #292524;
  --surface-2: #44403c;
  --text: #fafaf9;
  --muted: #a8a29e;
  --border: #44403c;
  --primary: #f59e0b;
  --primary-hover: #fbbf24;
  --accent: #d97706;
  --accent-light: #451a03;
  --tag-bg: #451a03;
  --tag-text: #fde68a;
  --code-bg: #0c0a09;
  --code-text: #fafaf9;
  --success: #22c55e;
  --warning: #f59e0b;
  --shadow: none;
  --header-bg: linear-gradient(135deg, #451a03 0%, #1c1917 40%, #292524 100%);
}

@media (prefers-color-scheme: dark) {
  html[data-theme="system"] {
    color-scheme: dark;
    --bg: #1c1917;
    --surface: #292524;
    --surface-2: #44403c;
    --text: #fafaf9;
    --muted: #a8a29e;
    --border: #44403c;
    --primary: #f59e0b;
    --primary-hover: #fbbf24;
    --accent: #d97706;
    --accent-light: #451a03;
    --tag-bg: #451a03;
    --tag-text: #fde68a;
    --code-bg: #0c0a09;
    --code-text: #fafaf9;
    --success: #22c55e;
    --warning: #f59e0b;
    --shadow: none;
    --header-bg: linear-gradient(135deg, #451a03 0%, #1c1917 40%, #292524 100%);
  }
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
  transition: background .3s ease, color .3s ease;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color .15s ease;
}
a:hover {
  color: var(--primary-hover);
}

/* ===== Header ===== */
.site-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  padding: 48px 24px 40px;
  transition: background .3s ease;
}

.hero {
  max-width: 1180px;
  margin: 0 auto;
}

.eyebrow {
  font-size: .875rem;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 8px;
}

.hero h1 {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -.02em;
  color: var(--text);
  margin-bottom: 12px;
}

.hero__desc {
  font-size: 1.05rem;
  color: var(--muted);
  max-width: 680px;
}

/* ===== Main Shell ===== */
.app-shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

/* ===== Toolbar ===== */
.toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 200px;
  max-width: 420px;
}

#searchInput {
  width: 100%;
  padding: 8px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: .9rem;
  font-family: inherit;
  transition: border-color .15s ease, box-shadow .15s ease;
}
#searchInput::placeholder {
  color: var(--muted);
}
#searchInput:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(217, 119, 6, .15);
}

.theme-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .875rem;
  color: var(--muted);
  flex-shrink: 0;
}

#themeSelect {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
  font-size: .875rem;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .15s ease;
}
#themeSelect:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ===== Filter Chips ===== */
.filter-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 24px;
  min-height: 0;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 5px 14px;
  border-radius: 999px;
  font-size: .8rem;
  font-weight: 500;
  font-family: inherit;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all .15s ease;
  user-select: none;
}
.filter-chip:hover {
  border-color: var(--primary);
  color: var(--text);
}
.filter-chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.filter-chip--active {
  background: var(--tag-bg);
  color: var(--tag-text);
  border-color: var(--primary);
  font-weight: 600;
}

/* ===== Project Grid ===== */
.project-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 24px;
}

@media (min-width: 1180px) {
  .project-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .project-grid {
    grid-template-columns: 1fr;
  }
  .hero h1 {
    font-size: 1.8rem;
  }
}

/* ===== Project Card ===== */
.project-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px;
  transition: transform .2s ease, box-shadow .2s ease, border-color .2s ease;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

.project-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: var(--primary);
  opacity: 0;
  transition: opacity .2s ease;
}

.project-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--primary);
}
.project-card:hover::before {
  opacity: 1;
}

/* ===== Card Header ===== */
.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  transition: background .2s ease;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
  flex: 1;
}

/* ===== Card Body ===== */
.card-desc {
  font-size: .925rem;
  color: var(--muted);
  line-height: 1.55;
  flex: 1;
}

/* ===== Card Meta ===== */
.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.tag {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 600;
  background: var(--tag-bg);
  color: var(--tag-text);
  border: none;
  cursor: default;
}

.tag--link {
  cursor: pointer;
}
.tag--link:hover {
  filter: brightness(0.95);
}

/* ===== Card Links ===== */
.card-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: auto;
  padding-top: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
  font-family: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: all .15s ease;
  border: none;
}

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

.btn--outline {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn--outline:hover {
  background: var(--accent-light);
  color: var(--primary-hover);
}

.btn--ghost {
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
}
.btn--ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

/* ===== Loading & Message ===== */
.loading-text {
  text-align: center;
  padding: 3rem;
  color: var(--muted);
  font-size: .95rem;
}

.message-box {
  text-align: center;
  padding: 48px 24px;
}

.message-box--error {
  color: var(--warning);
}

.message-box p {
  margin-bottom: 16px;
}

/* ===== Empty State ===== */
.empty-state {
  text-align: center;
  padding: 64px 24px;
  color: var(--muted);
  display: none;
}

.empty-state h2 {
  font-size: 1.25rem;
  margin-bottom: 8px;
  color: var(--text);
}

/* ===== Footer ===== */
.site-footer {
  max-width: 1180px;
  margin: 0 auto;
  padding: 32px 24px;
  text-align: center;
  font-size: .85rem;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.site-footer p {
  margin-bottom: 6px;
}

/* ===== Icons (inline SVG) ===== */
.icon-svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

/* ===== Accessibility ===== */
.skip-link {
  position: absolute;
  top: -100%;
  left: 16px;
  padding: 8px 20px;
  background: var(--primary);
  color: #fff;
  border-radius: 0 0 10px 10px;
  font-size: .9rem;
  font-weight: 600;
  z-index: 1000;
  text-decoration: none;
  transition: top .15s ease;
}
.skip-link:focus {
  top: 0;
  outline: none;
}

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

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