/* === BRAND VARIABLES (from Flashcards) === */
:root {
  --brand-green: #3b7a57;
  --brand-accent: #f4d35e;
  --clr-bg: #f5f5f5;
  --clr-panel: #fff;
  --clr-text: #333;
  --clr-text-light: #777;
  --gap: 2rem;
  --shadow-sm: 0 2px 6px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* === Bootstrap brand overrides to match Flashcards === */
.bg-success {
  background-color: var(--brand-green) !important;
}
.text-success {
  color: var(--brand-green) !important;
}
.border-success {
  border-color: var(--brand-green) !important;
}
.btn-success {
  --bs-btn-color: #fff;
  --bs-btn-bg: var(--brand-green);
  --bs-btn-border-color: var(--brand-green);
  --bs-btn-hover-bg: #2f6046;
  --bs-btn-hover-border-color: #2f6046;
  --bs-btn-active-bg: #2a4d3a;
  --bs-btn-active-border-color: #2a4d3a;
  --bs-btn-disabled-bg: var(--brand-green);
  --bs-btn-disabled-border-color: var(--brand-green);
}
.btn-outline-success {
  --bs-btn-color: var(--brand-green);
  --bs-btn-border-color: var(--brand-green);
  --bs-btn-hover-bg: var(--brand-green);
  --bs-btn-hover-border-color: var(--brand-green);
  --bs-btn-hover-color: #fff;
}
.navbar-brand span {
  color: var(--brand-accent);
}

/* === Reset & base === */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html,
body {
  min-height: 100%;
  background: var(--clr-bg);
  color: var(--clr-text);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial,
    sans-serif;
  line-height: 1.6;
}
body {
  display: flex;
  flex-direction: column;
}

/* === Layout wrapper for Reader pages === */
.layout {
  flex: 1;
  display: flex;
  gap: var(--gap);
  padding: var(--gap);
}

/* === Header (non-Bootstrap fallback if used) === */
.site-header {
  background: var(--brand-green);
  color: #fff;
}
.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem var(--gap);
}
.site-title-link {
  color: inherit;
  text-decoration: none;
  font-weight: 700;
}
.site-title-link span {
  color: var(--brand-accent);
}
.site-title-link:hover {
  opacity: 0.85;
}

/* === Top nav (custom header) === */
.nav-list {
  display: flex;
  gap: 1.5rem;
  list-style: none;
}
.nav-list a,
.my-words-btn {
  color: inherit;
  text-decoration: none;
  font-weight: 500;
  transition: opacity 0.2s;
  background: none;
  border: none;
  cursor: pointer;
}
.nav-list a:hover,
.my-words-btn:hover {
  opacity: 0.8;
}

/* === Sidebar === */
.sidebar {
  flex: 0 0 200px;
  align-self: flex-start;
  background: var(--clr-panel);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}
.sidebar nav li {
  list-style: none;
}
.sidebar a {
  display: block;
  padding: 0.75rem 1rem;
  color: var(--brand-green);
  text-decoration: none;
  transition: background 0.2s, color 0.2s;
}
.sidebar a:hover {
  background: rgba(59, 122, 87, 0.1);
  color: var(--brand-green);
}

/* === Main === */
.main-content {
  flex: 1;
}
.main-content h2 {
  margin-bottom: 1rem;
  color: var(--brand-green);
}
.back-link {
  display: inline-block;
  margin-bottom: 1.5rem;
  color: var(--brand-green);
  text-decoration: none;
}
.back-link:hover {
  text-decoration: underline;
}
.page-image {
  display: block;
  width: 100%;
  max-width: 600px;
  height: auto;
  margin: 0 auto var(--gap);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
}

/* === Cards === */
.cards-container {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}
.card {
  background: var(--clr-panel);
  border-radius: 8px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s, opacity 0.3s ease;
}
.card.hidden {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
}
.card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}
.card img {
  width: 100%;
  height: 140px;
  object-fit: cover;
}
.card-content {
  padding: 1rem;
}
.card-content h3 {
  margin-bottom: 0.5rem;
  font-size: 1.1rem;
  color: var(--brand-green);
}
.card-content p {
  margin-bottom: 0.75rem;
  font-size: 0.95rem;
  color: #555;
}

/* === Footer (align with Flashcards) === */
.site-footer {
  background: #222;
  text-align: center;
  padding: 1rem;
  font-size: 0.9rem;
  color: #fff;
}

/* === Tooltip === */
.has-tooltip {
  position: relative;
  cursor: help;
  text-decoration: underline dotted;
}
.has-tooltip::after {
  content: attr(data-translation);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 0.2em 0.4em;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 0.85em;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease-in-out;
  z-index: 10;
}
.has-tooltip:hover::after,
.has-tooltip:focus::after {
  opacity: 1;
}

/* === Difficulty bars === */
.difficulty {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  font-size: 0.95rem;
}
.level-text.beginner {
  color: #2e7d32;
}
.level-text.intermediate {
  color: #ed6c02;
}
.level-text.advanced {
  color: #d32f2f;
}
.difficulty-bar {
  flex: 1;
  height: 8px;
  background: #e0e0e0;
  border-radius: 4px;
  overflow: hidden;
}
.difficulty-bar.beginner .difficulty-fill {
  width: 20%;
  background: #2e7d32;
}
.difficulty-bar.intermediate .difficulty-fill {
  width: 60%;
  background: #ed6c02;
}
.difficulty-bar.advanced .difficulty-fill {
  width: 100%;
  background: #d32f2f;
}
.difficulty-fill {
  height: 100%;
  transition: width 0.3s ease-in-out;
}

/* === Filter bar === */
.filter-bar {
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.filter-bar select {
  border-radius: 4px;
  border: 1px solid #ccc;
}
.filter-bar select:focus {
  border-color: var(--brand-green);
  box-shadow: 0 0 0 0.25rem rgba(59, 122, 87, 0.25);
  outline: none;
}

/* === Modal (My Words) === */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
}
.modal-content {
  display: flex;
  flex-direction: column;
  background: #fff;
  margin: 10% auto;
  padding: 1rem;
  border-radius: 8px;
  width: 90%;
  max-width: 500px;
  box-shadow: var(--shadow-md);
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -1rem -1rem 0 -1rem;
}

.modal-header .close {
  align-self: flex-end;
  font-size: 2rem;
  cursor: pointer;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.4rem;
}

#myWordsList {
  list-style: none;
  padding: 0;
  margin: 0;
}
#myWordsList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.25rem 0;
  border-bottom: 1px solid #ddd;
}
#myWordsList li span {
  display: inline-block;
}
#myWordsList strong {
  font-weight: bold;
  color: var(--brand-green);
  text-transform: lowercase;
}
.delete-word {
  background: none;
  border: none;
  color: #d32f2f;
  font-size: 1rem;
  cursor: pointer;
}
.delete-word:hover {
  opacity: 0.7;
}
.clear-btn {
  margin-top: 1rem;
  background: #d32f2f;
  color: #fff;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  cursor: pointer;
}
.clear-btn:hover {
  opacity: 0.85;
}

/* === Focus styles (accessibility, match Flashcards) === */
button:focus {
  outline: none;
}
button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 2px solid var(--brand-green);
  outline-offset: 2px;
}

/* === Responsive === */
@media (max-width: 768px) {
  .layout {
    flex-direction: column;
  }
  .sidebar {
    width: 100%;
    margin-bottom: 1.5rem;
  }
}
@media (max-width: 600px) {
  .header-inner {
    flex-direction: column;
    gap: 0.75rem;
  }
  .nav-list {
    flex-wrap: wrap;
    justify-content: center;
  }
}

#huText {
  color: #212529;
}

#huText p {
  margin-bottom: 1rem;
}

.ko-fi-widget {
  margin-top: 1rem;
  text-align: center;
  font-family: inherit;
}

.ko-fi-widget iframe:hover {
  filter: brightness(1.1) drop-shadow(0 0 4px var(--brand-accent));
  transition: filter 0.2s ease-in-out;
}

#interactionTip {
  background: rgba(0, 0, 0, 0.03);
  padding: 0.5rem 0.75rem;
  border-radius: 4px;
  font-size: 0.85rem;
  color: var(--clr-text-light);
}

#comprehension h3 {
  margin-bottom: 1rem;
  color: var(--brand-green);
}

#markAsReadBtn {
  background-color: var(--brand-green);
  color: white;
  border: none;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

#markAsReadBtn:hover {
  transform: scale(1.03);
  cursor: pointer;
}

#markAsUnreadBtn {
  display: none;
}

#readConfirmation {
  display: none;
}

/* === My Words button in sidebar === */
.sidebar {
  flex: 0 0 220px;
  background: var(--clr-panel);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-widget {
  background: var(--clr-panel);
  border-radius: 8px;
  box-shadow: var(--shadow-sm);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.sidebar-widget h5 {
  margin-bottom: 0.5rem;
  font-size: 1rem;
  color: var(--brand-green);
}

/* My Words button */
.btn-mywords {
  background-color: var(--brand-green);
  color: white;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: 0.9rem;
  transition: background-color 0.3s ease, transform 0.2s ease;
  cursor: pointer;

  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;

  display: block;
  margin: 0 auto;
  text-align: center;
}

.btn-mywords:hover {
  background-color: var(--brand-accent);
  color: var(--clr-text);
}

/* Progress bar */
.progress {
  height: 20px;
  background: #e0e0e0;
  border-radius: 10px;
  overflow: hidden;
}

.progress-bar {
  background-color: var(--brand-green);
  height: 100%;
  width: 0%;
  transition: width 0.6s ease;
}

.sidebar-widget h5::before {
  content: "★";
  color: var(--brand-accent);
  margin-right: 0.25rem;
}

.btn-toggle-tooltips {
  background-color: var(--brand-accent);
  color: #333;
  border: none;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: 0.9rem;
  cursor: pointer;
  display: block;
  margin: 0 auto;
  text-align: center;
}
.btn-toggle-tooltips:hover {
  opacity: 0.85;
}

.has-tooltip.no-underline {
  text-decoration: none;
}
