/*
 * Override bootstrap-icons font-display from "block" to "swap" so the icon
 * font never holds layout hostage while downloading.  "swap" shows the
 * fallback glyph immediately and swaps in the icon font once it arrives,
 * eliminating the font-caused layout shift on the search input.
 */
@font-face {
  font-family: "bootstrap-icons";
  font-display: swap;
  src: url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/fonts/bootstrap-icons.woff2?dd67030699838ea613ee6dbda90effa6") format("woff2"),
       url("https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/fonts/bootstrap-icons.woff?dd67030699838ea613ee6dbda90effa6") format("woff");
}

body {
  margin: 0;
  min-width: 300px;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.page-title {
  color: #8a6530;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.page-subtitle {
  color: #666;
  font-size: 0.9rem;
  letter-spacing: 0.03em;
}

.site-nav {
  background-color: #1a1a1a;
  min-height: 60px;
  padding-top: 0.25rem;
  padding-bottom: 0.25rem;
}

.lang-select-wrap {
  position: relative;
  flex-shrink: 0;
}

.lang-select {
  background-color: transparent;
  border: none;
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.lang-select:focus {
  outline: none;
  border-color: #ba945e;
}

.lang-select-current {
  display: none;
}

.lang-select-globe {
  border-radius: 999px;
  padding: 0.25rem 0.55rem;
  border: 1px solid rgba(186, 148, 94, 0.45);
  background: rgba(186, 148, 94, 0.12);
  transition: background 0.2s ease, border 0.2s ease;
}

.lang-select-globe:hover,
.lang-select-globe:focus-visible {
  border-color: #f7e4c6;
  background: rgba(186, 148, 94, 0.25);
}

.lang-select-globe i {
  font-size: 1rem;
}

.lang-select-current-code {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
}

.lang-select-caret {
  font-size: 0.72rem;
  opacity: 0.8;
  transition: transform 0.18s ease;
}

.lang-select[aria-expanded="true"] .lang-select-caret {
  transform: rotate(180deg);
}

.lang-select-menu {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  background-color: #1e1e1e;
  border: 1px solid rgba(186, 148, 94, 0.4);
  border-radius: 12px;
  padding: 0.35rem;
  display: flex;
  flex-direction: row;
  gap: 0.15rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.04);
  z-index: 2100;
  animation: lang-menu-in 0.15s ease;
}

@keyframes lang-menu-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.lang-select-option {
  background: transparent;
  border: 1px solid transparent;
  color: #c0c0c0;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.55rem;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
}

.lang-select-option:hover {
  background-color: rgba(186, 148, 94, 0.12);
  color: #f1d6ad;
  border-color: rgba(186, 148, 94, 0.25);
}

.lang-select-option.is-selected {
  background-color: rgba(186, 148, 94, 0.15);
  border-color: rgba(186, 148, 94, 0.55);
  color: #f5dfbd;
}

.lang-option-code {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  opacity: 0.85;
}

.lang-flag {
  width: 1.6rem;
  height: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lang-flag-emoji {
  font-size: 1.15rem;
  line-height: 1;
}

.lang-flag-svg img {
  width: 72%;
  height: 72%;
  object-fit: contain;
  display: block;
  border-radius: 2px;
}

.lang-select-native {
  pointer-events: none;
}

.site-nav-inner {
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0 0.5rem;
}

.site-nav-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.site-nav-title {
  font-size: 1.15rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  font-weight: 600;
  color: #f7e4c6;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.3);
  padding-bottom: 2px;
  text-decoration: none;
}

.site-nav-title:hover {
  color: #f7e4c6;
}

.site-nav .container-fluid {
  flex-wrap: nowrap !important;
}

.site-nav .container-fluid > a,
.site-nav .lang-select-wrap {
  flex-shrink: 0;
}

.site-nav .container-fluid > form[role="search"] {
  flex: 1 1 auto;
  min-width: 0;
}

.site-nav-search {
  max-width: 360px;
  min-width: 0;
  flex: 1 1 120px;
  background-color: #2a2a2a;
  border: 1px solid #3a3a3a;
  border-radius: 6px;
  color: #ddd;
  font-size: 0.875rem;
  padding: 0.35rem 0.6rem 0.35rem 0.65rem;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.site-nav-search::placeholder {
  color: #666;
}

.site-nav-search:focus {
  border-color: #ba945e;
  box-shadow: 0 0 0 2px rgba(186, 148, 94, 0.2);
}

.site-nav-search::-webkit-search-cancel-button {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  margin-left: 0.45rem;
  border-radius: 50%;
  background-color: rgba(186, 148, 94, 0.9);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M4.47 4.47 11.53 11.53M11.53 4.47 4.47 11.53' stroke='white' stroke-width='1.8' stroke-linecap='round'/%3E%3C/svg%3E");
  background-position: center;
  background-repeat: no-repeat;
  background-size: 10px 10px;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.site-nav-search::-webkit-search-cancel-button:hover {
  background-color: #ba945e;
  box-shadow: 0 0 0 1px rgba(186, 148, 94, 0.25);
}

.site-nav-search::-webkit-search-cancel-button:active {
  transform: scale(0.92);
  background-color: #a07840;
}

.site-footer {
  background-color: #1a1a1a;
  padding: 1rem 1rem max(1rem, env(safe-area-inset-bottom));
}

.site-footer-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
}

.site-footer-divider {
  color: #ba945e;
  font-size: 0.75rem;
  letter-spacing: 0.2em;
  opacity: 0.7;
}

.site-footer-text {
  color: #888;
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.site-footer-version {
  color: #555;
  font-size: 0.72rem;
  letter-spacing: 0.04em;
}

.exercise-stats-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.exercise-stats {
  font-size: 0.8rem;
  font-style: italic;
  color: #ba945e;
  letter-spacing: 0.02em;
  min-height: 1.2em;
  margin: 0.5rem 0 0;
  padding: 0 0.25rem;
}

.section-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, #ba945e 30%, #ba945e 70%, transparent);
  margin: 0.5rem 0 0;
  opacity: 0.5;
}

.pyscript {
  margin: 0.5rem;
}

html {
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  line-height: 1.5;
}

nav {
  position: sticky;
  width: 100%;
  top: 0;
  left: 0;
  z-index: 9999;
}

.logo-header {
  width: 50px;
  height: 50px;
}

#loading {
  outline: none;
  border: none;
  background: transparent;
}

.logo {
  width: 50px;
  height: 50px;
}

.pulsate {
  animation: pulsate 1.5s ease-in-out infinite;
}

@keyframes pulsate {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.3);
    opacity: 0.4;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.title {
  text-decoration: none;
  
  font-weight: 400;
  font-size: 1.5em;
  line-height: 2em;
  white-space: nowrap;
}

.app-header {
  display: flex;
  align-items: center;
  padding: 0.25rem 0.5rem;
}

@media (max-width: 576px) {
  .logo-header {
    height: 46px;
  }

  .lang-select {
    min-width: 4.1rem;
    padding: 5px 8px;
  }

  .lang-select-current-label {
    display: none;
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .title {
    font-size: 1.25em;
    line-height: 1.5em;
  }

  .logo {
    height: 60px;
  }
}

@keyframes card-fade-in {
  from {
    opacity: 0;
    transform: translateY(-12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card-animate {
  animation: card-fade-in 0.3s ease both;
}

.exercise-card {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.exercise-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  position: relative;
  z-index: 901;
}

.exercise-card:has(.exercise-overlay):hover {
  transform: none;
  box-shadow: none;
  z-index: auto;
  cursor: default;
}

.card-img-area {
  background-color: #f8f9fa;
  border-bottom: 1px solid #e9ecef;
  position: relative;
}

.equipment-badge--card {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
}

.card-img-top {
  height: 160px;
  object-fit: contain;
  width: 100%;
  display: block;
  /* aspect-ratio derived from the width/height HTML attributes (320×160 = 2:1)
     lets the browser pre-reserve the 160 px slot before CSS has applied. */
  aspect-ratio: auto 320 / 160;
}

.card-title-link {
  color: #212529;
  transition: color 0.2s ease;
}

.card-title-link:hover,
.exercise-card:hover .card-title-link {
  color: #ba945e;
}

.exercise-card:has(.exercise-overlay):hover .card-title-link {
  color: #212529;
}

.card-actions {
  border-top: 1px solid #e9ecef;
  padding-top: 0.2rem;
}

.card-action-icon {
  color: #ba945e;
  cursor: pointer;
  padding: 0.2rem;
  min-width: 36px;
  min-height: 36px;
  transition: transform 0.2s ease, opacity 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.card-action-icon--danger {
  color: #e05252 !important;
}

#exercises-row > div {
  align-self: flex-start;
}

.custom-actions-row {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 2px;
  padding-bottom: 4px;
  margin-bottom: 4px;
}

.custom-action-icon {
  font-size: 1rem !important;
  min-width: 28px;
  min-height: 28px;
}

.card-action-icon:hover {
  transform: scale(1.2);
  opacity: 0.8;
}

.exercise-card .card-body {
  padding: 0.45rem 0.75rem;
}

.exercise-card .card-title {
  font-size: 1.05rem;
  margin-bottom: 0.6rem;
}

.exercise-card .badge {
  font-size: 0.65rem;
  padding: 0.2em 0.4em;
}

.badge.bg-info {
  color: #212529;
}

.badge-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
}

.equipment-badge {
  background-color: transparent;
  border: 1px solid #6c757d;
  color: #6c757d;
  cursor: default;
}

.equipment-badge:has(.bi-lightning-fill) {
  border-color: #ba945e;
  color: #ba945e;
}
