/* Theme Variables */
:root {
  /* Light theme (default) */
  --primary-color: #ff6b00;
  --secondary-color: #444;
  --text-color: #333;
  --light-text: #666;
  --bg-color: #fff;
  --light-bg: #f5f5f5;
  --border-color: #ddd;
  --link-color: #0066cc;
  --link-hover: #004080;
  --success-color: #28a745;
  --error-color: #dc3545;
  --warning-color: #ffc107;
  --card-bg: #fff;
  --header-bg: #f5f5f5;
  --footer-bg: #f5f5f5;
  --shadow-color: rgba(0, 0, 0, 0.1);
  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Dark theme */
[data-theme="dark"] {
  --primary-color: #ff8c3f;
  --secondary-color: #aaa;
  --text-color: #e0e0e0;
  --light-text: #aaa;
  --bg-color: #121212;
  --light-bg: #1e1e1e;
  --border-color: #444;
  --link-color: #4d9dff;
  --link-hover: #77b6ff;
  --success-color: #3dd06c;
  --error-color: #ff5c5c;
  --warning-color: #ffd04d;
  --card-bg: #1e1e1e;
  --header-bg: #1a1a1a;
  --footer-bg: #1a1a1a;
  --shadow-color: rgba(0, 0, 0, 0.3);
}

/* Theme transition */
* {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.moon-icon,
.sun-icon {
  width: 16px;
  height: 16px;
  display: inline-block;
}

.moon-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='%23000000' d='M283.211 512c78.962 0 151.079-35.925 198.857-94.792 7.068-8.708-.639-21.43-11.562-19.35-124.203 23.654-238.262-71.576-238.262-196.954 0-72.222 38.662-138.635 101.498-174.394 9.686-5.512 7.25-20.197-3.756-22.23A258.156 258.156 0 0 0 283.211 0c-141.309 0-256 114.511-256 256 0 141.309 114.511 256 256 256z'%3E%3C/path%3E%3C/svg%3E");
}

.sun-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath fill='%23000000' d='M256 160c-52.9 0-96 43.1-96 96s43.1 96 96 96 96-43.1 96-96-43.1-96-96-96zm246.4 80.5l-94.7-47.3 33.5-100.4c4.5-13.6-8.4-26.5-21.9-21.9l-100.4 33.5-47.4-94.8c-6.4-12.8-24.6-12.8-31 0l-47.3 94.7L92.7 70.8c-13.6-4.5-26.5 8.4-21.9 21.9l33.5 100.4-94.7 47.4c-12.8 6.4-12.8 24.6 0 31l94.7 47.3-33.5 100.5c-4.5 13.6 8.4 26.5 21.9 21.9l100.4-33.5 47.3 94.7c6.4 12.8 24.6 12.8 31 0l47.3-94.7 100.4 33.5c13.6 4.5 26.5-8.4 21.9-21.9l-33.5-100.4 94.7-47.3c13-6.5 13-24.7.2-31.1zm-155.9 106c-49.9 49.9-131.1 49.9-181 0-49.9-49.9-49.9-131.1 0-181 49.9-49.9 131.1-49.9 181 0 49.9 49.9 49.9 131.1 0 181z'%3E%3C/path%3E%3C/svg%3E");
}

[data-theme="dark"] .moon-icon {
  filter: invert(1);
}

[data-theme="dark"] .sun-icon {
  filter: invert(1);
}

/* Base styles */
html,
body {
  overflow-x: hidden;
  width: 100%;
  position: relative;
}

body {
  font-family: var(--font-family);
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
  margin: 0;
  padding: 0;
}

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

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

img {
  max-width: 100%;
  height: auto;
}

[data-theme="dark"] img {
  filter: brightness(0.9);
  /* Slightly reduce brightness for better contrast */
}

/* Layout */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 15px;
  box-sizing: border-box;
}

main {
  padding: 2rem 0 !important;
}

.row {
  display: flex;
  flex-wrap: wrap;
  margin: 0 -15px;
}

.col {
  flex: 1;
  padding: 0 15px;
}

/* For a 12-column grid system */
.col-1 {
  flex: 0 0 8.333333%;
  max-width: 8.333333%;
}

.col-2 {
  flex: 0 0 16.666667%;
  max-width: 16.666667%;
}

.col-3 {
  flex: 0 0 25%;
  max-width: 25%;
}

.col-4 {
  flex: 0 0 33.333333%;
  max-width: 33.333333%;
}

.col-6 {
  flex: 0 0 50%;
  max-width: 50%;
}

.col-8 {
  flex: 0 0 66.666667%;
  max-width: 66.666667%;
}

.col-9 {
  flex: 0 0 75%;
  max-width: 75%;
}

.col-12 {
  flex: 0 0 100%;
  max-width: 100%;
}

/* Responsive adjustments */
@media (max-width: 768px) {

  .col-md-3,
  .col-md-4,
  .col-md-6,
  .col-md-8 {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
  margin-bottom: 0.5rem;
  font-weight: 500;
  line-height: 1.2;
}

h1 {
  font-size: 2.5rem;
}

h2 {
  font-size: 2rem;
}

h3 {
  font-size: 1.75rem;
}

h4 {
  font-size: 1.5rem;
}

h5 {
  font-size: 1.25rem;
}

h6 {
  font-size: 1rem;
}

p {
  margin-bottom: 1rem;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

/* Header & Navigation */
header {
  background-color: var(--header-bg);
  padding: 1rem 0;
  border-bottom: 1px solid var(--border-color);
}

.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
}

.navbar-brand {
  display: flex;
  align-items: center;
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--primary-color);
}

.navbar-logo {
  height: 40px;
  margin-right: 10px;
}

.navbar-nav {
  display: flex;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-item {
  margin-right: 1rem;
}

.nav-link {
  color: var(--secondary-color);
  padding: 0.5rem;
}

.nav-link:hover {
  color: var(--primary-color);
}

.search-form {
  display: flex;
}

.search-input {
  padding: 0.5rem;
  color: var(--text-color);
  background-color: var(--bg-color);
  border: 1px solid var(--border-color);
  border-radius: 4px 0 0 4px;
  font-size: 1rem;
}

.search-button {
  padding: 0.5rem 1rem;
  background-color: var(--primary-color);
  color: white;
  border: none;
  border-radius: 0 4px 4px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.search-button:hover {
  background-color: var(--link-hover);
}

.search-button img {
  filter: brightness(0) invert(1);
}

/* Cards */
.card {
  border: 1px solid var(--border-color);
  border-radius: 4px;
  margin-bottom: 1rem;
  background-color: var(--card-bg);
  box-shadow: 0 2px 4px var(--shadow-color);
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  overflow: hidden;
}

.card-img-top {
  width: 100%;
  height: auto;
  object-fit: cover;
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

[data-theme="dark"] .card-img-top {
  opacity: 0.9;
  /* Slightly reduce opacity for better contrast */
}

.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.card-title {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  /* Limit to 2 lines of text */
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-text {
  color: var(--light-text);
  margin-bottom: 0;
  /* Limit to 3 lines of text */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-footer {
  padding-bottom: 1rem;
  background-color: var(--light-bg);
  border-top: 1px solid var(--border-color);
  margin-top: auto;
  /* Push footer to bottom of card */
}

/* Grid layout for cards */
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
  margin: 1.5rem 0;
}

@media (max-width: 768px) {
  .card-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }
}

@media (max-width: 576px) {
  .card-grid {
    grid-template-columns: 1fr;
  }

  .card-img-top {
    height: 180px;
  }
}

/* Channel grid layout */
.channel-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 1.5rem 0;
}

.channel-grid .btn {
  margin: 0.25rem;
}

/* Sort links */
.sort-links {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
  margin: 1.5rem 0;
}

.sort-links a {
  margin: 0.25rem;
}

/* Buttons */
.btn {
  display: inline-block;
  font-weight: 400;
  text-align: center;
  white-space: nowrap;
  vertical-align: middle;
  user-select: none;
  border: 1px solid transparent;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  border-radius: 0.25rem;
  transition: all 0.15s ease-in-out;
  cursor: pointer;
}

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

.btn-primary:hover {
  background-color: var(--link-hover);
  border-color: var(--link-hover);
}

.btn-outline-success {
  color: var(--success-color);
  background-color: transparent;
  border-color: var(--success-color);
}

.btn-outline-success:hover {
  color: #fff;
  background-color: var(--success-color);
  border-color: var(--success-color);
}

.btn-outline-primary {
  color: var(--primary-color);
  background-color: transparent;
  border-color: var(--primary-color);
}

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

/* Forms */
.form-control {
  display: block;
  width: 100%;
  padding: 0.375rem 0.75rem;
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-color);
  background-color: var(--bg-color);
  background-clip: padding-box;
  border: 1px solid var(--border-color);
  border-radius: 0.25rem;
  transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.form-control:focus {
  color: var(--text-color);
  background-color: var(--bg-color);
  border-color: var(--primary-color);
  outline: 0;
  box-shadow: 0 0 0 0.2rem rgba(255, 107, 0, 0.25);
}

/* Utilities */
.mb-1 {
  margin-bottom: 0.25rem;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-3 {
  margin-bottom: 1rem;
}

.mb-4 {
  margin-bottom: 1.5rem;
}

.mb-5 {
  margin-bottom: 3rem;
}

.mt-1 {
  margin-top: 0.25rem;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mt-3 {
  margin-top: 1rem;
}

.mt-4 {
  margin-top: 1.5rem;
}

.mt-5 {
  margin-top: 3rem;
}

.my-1 {
  margin-top: 0.25rem;
  margin-bottom: 0.25rem;
}

.my-2 {
  margin-top: 0.5rem;
  margin-bottom: 0.5rem;
}

.my-3 {
  margin-top: 1rem;
  margin-bottom: 1rem;
}

.my-4 {
  margin-top: 1.5rem;
  margin-bottom: 1.5rem;
}

.my-5 {
  margin-top: 3rem;
  margin-bottom: 3rem;
}

.p-1 {
  padding: 0.25rem;
}

.p-2 {
  padding: 0.5rem;
}

.p-3 {
  padding: 1rem;
}

.p-4 {
  padding: 1.5rem;
}

.p-5 {
  padding: 3rem;
}

.py-1 {
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.py-2 {
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
}

.py-3 {
  padding-top: 1rem;
  padding-bottom: 1rem;
}

.py-4 {
  padding-top: 1.5rem;
  padding-bottom: 1.5rem;
}

.py-5 {
  padding-top: 3rem;
  padding-bottom: 3rem;
}

.px-1 {
  padding-left: 0.25rem;
  padding-right: 0.25rem;
}

.px-2 {
  padding-left: 0.5rem;
  padding-right: 0.5rem;
}

.px-3 {
  padding-left: 1rem;
  padding-right: 1rem;
}

.px-4 {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

.px-5 {
  padding-left: 3rem;
  padding-right: 3rem;
}

.d-flex {
  display: flex;
}

.flex-column {
  flex-direction: column;
}

.justify-content-center {
  justify-content: center;
}

.justify-content-between {
  justify-content: space-between;
}

.align-items-center {
  align-items: center;
}

.shadow-sm {
  box-shadow: 0 .125rem .25rem rgba(0, 0, 0, .075);
}

.rounded {
  border-radius: 0.25rem;
}

/* Project lists */
.ible-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  margin: 2rem 0;
}

.ible-list-item {
  flex: 0 0 calc(33.333% - 1.5rem);
  max-width: calc(33.333% - 1.5rem);
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease-in-out;
}

.ible-list-item:hover {
  transform: translateY(-5px);
}

.ible-list-item img {
  width: 100%;
  height: auto;
  object-fit: cover;
}

.ible-list-item p {
  padding: 0.5rem;
  margin: 0;
}

.ible-small {
  font-size: 0.875rem;
  color: var(--light-text);
}

@media (max-width: 992px) {
  .ible-list-item {
    flex: 0 0 calc(50% - 1.5rem);
    max-width: calc(50% - 1.5rem);
  }
}

@media (max-width: 576px) {
  .ible-list-item {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* Member profiles */
.member-list {
  margin-bottom: 1.5rem;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background-color: var(--light-bg);
}

/* Step sections in articles */
.step-images {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  justify-content: center;
  width: 100%;
  box-sizing: border-box;
}

.step-images .col-md-4 {
  flex: 0 0 auto;
  width: 100%;
  box-sizing: border-box;
  padding: 0;
}

@media (min-width: 576px) {
  .step-images {
    gap: 1rem;
  }

  .step-images .col-md-4 {
    max-width: 350px;
  }
}

.step-images img {
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 0.25rem;
  box-shadow: 0 2px 4px var(--shadow-color);
  box-sizing: border-box;
  object-fit: contain;
}

.step-images img:hover {
  transform: scale(1.02);
}

.step-section {
  margin-bottom: 2rem;
  padding: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 0.5rem;
  background-color: var(--card-bg);
  box-shadow: 0 2px 8px var(--shadow-color);
  width: 100%;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .step-section {
    max-width: 1000px;
    padding: 1.5rem;
    margin-left: auto;
    margin-right: auto;
  }
}

.step-section img {
  max-width: 100%;
  height: auto;
  box-sizing: border-box;
}

.step-header {
  margin-bottom: 1.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.step-header h2 {
  margin-bottom: 0;
  color: var(--primary-color);
}

/* Hide step-header when h2 is empty */
.step-header:has(h2:empty),
.step-header h2:empty {
  display: none;
}

/* Step parts */
.step-text {
  line-height: 1.7;
  margin-bottom: 1rem;
  width: 100%;
  box-sizing: border-box;
}

.step-text *:not(img):not(iframe):not(embed):not(object):not(video) {
  max-width: 100%;
  box-sizing: border-box;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.step-videos,
.step-iframes {
  margin-bottom: 1.5rem;
}

.step-downloads {
  width: 100%;
  box-sizing: border-box;
  margin-top: 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
}

.step-downloads .row {
  width: 100%;
  margin: 0;
  box-sizing: border-box;
}

.step-downloads .col-md-2 {
  padding: 0 0.25rem;
  margin-bottom: 0.5rem;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .step-downloads {
    margin-top: 1.5rem;
    padding-top: 1rem;
  }
}

.step-downloads h3 {
  margin-bottom: 0.5rem;
  font-size: 1.25rem;
  color: var(--primary-color);
}

@media (min-width: 768px) {
  .step-downloads h3 {
    margin-bottom: 1rem;
  }
}

.step-downloads .col-md-2 {
  flex: 0 0 auto;
  width: 100%;
  margin-bottom: 0.5rem;
}

@media (min-width: 576px) {
  .step-downloads .col-md-2 {
    width: 50%;
  }
}

@media (min-width: 768px) {
  .step-downloads .col-md-2 {
    width: 33.333%;
  }
}

@media (min-width: 992px) {
  .step-downloads .col-md-2 {
    width: 16.666%;
  }
}

.step-iframes {
  width: 100%;
  box-sizing: border-box;
  margin-bottom: 1rem;
}

.step-iframes .col-md-8 {
  width: 100%;
  box-sizing: border-box;
  padding: 0;
}

iframe,
embed,
object,
video {
  max-width: 100%;
  box-sizing: border-box;
}

@media (min-width: 768px) {
  .step-iframes {
    margin-bottom: 1.5rem;
  }

  .step-iframes .col-md-8 {
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
  }
}

.step-iframes iframe {
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--border-color);
  border-radius: 0.25rem;
}

@media (min-width: 768px) {
  .step-iframes iframe {
    max-height: 450px;
    height: 450px;
  }
}

[data-theme="dark"] .step-section {
  background-color: var(--card-bg);
}

[data-theme="dark"] .step-header h2 {
  color: var(--primary-color);
}

[data-theme="dark"] .step-downloads h3 {
  color: var(--primary-color);
}

/* Contest lists */
.contest-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1.5rem;
  margin: 2rem 0;
}

.contest-list-item {
  flex: 0 0 calc(50% - 1.5rem);
  max-width: calc(50% - 1.5rem);
  margin-bottom: 1.5rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.contest-list-item img {
  width: 100%;
  height: auto;
  object-fit: cover;
}

.contest-list-item h2 {
  padding: 1rem;
  margin: 0;
}

.contest-list-item p {
  padding: 0 1rem 1rem;
  margin: 0;
}

@media (max-width: 768px) {
  .contest-list-item {
    flex: 0 0 100%;
    max-width: 100%;
  }
}

/* Pagination */
.pagination {
  display: flex;
  justify-content: center;
  list-style: none;
  margin: 2rem 0;
}

.pagination-list {
  display: flex;
  list-style: none;
  gap: 0.5rem;
}

.page-item {
  margin: 0 0.25rem;
}

.page-link {
  display: block;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.25rem;
  color: var(--link-color);
  background-color: var(--bg-color);
  text-decoration: none;
}

.page-link:hover {
  background-color: var(--light-bg);
  text-decoration: none;
}

.page-link.active {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.page-link.disabled {
  color: var(--light-text);
  pointer-events: none;
  cursor: not-allowed;
}

/* Footer */
footer {
  background-color: var(--footer-bg);
  padding: 2rem 0;
  margin-top: 3rem;
  border-top: 1px solid var(--border-color);
}

/* Theme Toggle Switch */
.theme-switch-wrapper {
  display: flex;
  align-items: center;
  margin-left: 1rem;
}

.theme-switch {
  display: inline-block;
  height: 24px;
  position: relative;
  width: 50px;
}

.theme-switch input {
  display: none;
}

.slider {
  background-color: #ccc;
  bottom: 0;
  cursor: pointer;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  transition: .4s;
  border-radius: 34px;
}

.slider:before {
  background-color: white;
  bottom: 4px;
  content: "";
  height: 16px;
  left: 4px;
  position: absolute;
  transition: .4s;
  width: 16px;
  border-radius: 50%;
}

input:checked+.slider {
  background-color: var(--primary-color);
}

input:checked+.slider:before {
  transform: translateX(26px);
}

.theme-icon {
  margin-right: 5px;
  font-size: 1.2rem;
}

/* Error pages */
.error-page {
  text-align: center;
  padding: 3rem 0;
}

.error-page h1 {
  font-size: 5rem;
  margin-bottom: 1rem;
}

.error-page p {
  font-size: 1.5rem;
  margin-bottom: 2rem;
}

.go_here_link {
  display: inline-block;
  margin: 0.5rem;
  padding: 0.75rem 1.5rem;
  background-color: var(--primary-color);
  color: white;
  border-radius: 4px;
  text-decoration: none;
}

.go_here_link:hover {
  background-color: var(--link-hover);
  text-decoration: none;
}

/* Sitemap */
.sitemap-group {
  margin-bottom: 2rem;
}

/* Media queries for responsive design */
@media (max-width: 992px) {
  .container {
    max-width: 960px;
  }
}

@media (max-width: 768px) {
  .container {
    max-width: 720px;
  }

  .navbar {
    flex-direction: column;
  }

  .navbar-nav {
    margin-top: 1rem;
    width: 100%;
    justify-content: center;
  }

  .search-form {
    margin-top: 1rem;
    width: 100%;
  }
}

@media (max-width: 576px) {
  .container {
    max-width: 540px;
  }

  h1 {
    font-size: 2rem;
  }

  h2 {
    font-size: 1.75rem;
  }

  h3 {
    font-size: 1.5rem;
  }

  .card-title {
    font-size: 1.1rem;
  }
}