@import url("fonts.css");

:root {
  --bg: #F4F6F9;
  --card-bg: #FFFFFF;
  --card-border: rgba(20, 32, 43, 0.08);
  --ink: #111927;
  --ink-soft: #4B5565;
  --ink-faint: #9AA4B2;
  --primary: #0284C7;
  --primary-dark: #0369A1;
  --primary-soft: rgba(2, 132, 199, 0.08);
  --primary-border: rgba(2, 132, 199, 0.25);
  --accent: #0D9488;
  --accent-soft: rgba(13, 148, 136, 0.08);
  --tag-bg: #E2E8F0;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05), 0 1px 2px rgba(0,0,0,0.03);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.07), 0 2px 4px -2px rgba(0,0,0,0.05);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

[data-theme="dark"] {
  --bg: #0B111E;
  --card-bg: #151E2E;
  --card-border: rgba(255, 255, 255, 0.08);
  --ink: #F1F5F9;
  --ink-soft: #94A3B8;
  --ink-faint: #64748B;
  --primary: #38BDF8;
  --primary-dark: #0284C7;
  --primary-soft: rgba(56, 189, 248, 0.12);
  --primary-border: rgba(56, 189, 248, 0.25);
  --accent: #2DD4BF;
  --accent-soft: rgba(45, 212, 191, 0.12);
  --tag-bg: #1E293B;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 8px rgba(0,0,0,0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: inherit;
}

body {
  background: var(--bg);
  color: var(--ink);
  line-height: 1.6;
  padding-bottom: 60px;
  transition: background 0.2s, color 0.2s;
}

.header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--card-border);
  padding: 24px 0;
  box-shadow: var(--shadow-sm);
}

.container {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0 24px;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--ink);
  font-weight: 800;
  font-size: 20px;
}

.brand-badge {
  background: var(--primary);
  color: white;
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 800;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-selector-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--primary-soft);
  border: 1px solid var(--primary-border);
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
}

.lang-selector-wrap:hover {
  border-color: var(--primary);
}

.lang-globe {
  font-size: 14px;
  line-height: 1;
  display: inline-block;
}

.lang-select {
  background: transparent;
  border: none;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  font-family: inherit;
  padding-right: 2px;
}

.lang-select option {
  background: var(--card-bg);
  color: var(--ink);
}

.lang-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card-bg);
  color: var(--ink);
  border: 1px solid var(--primary);
  box-shadow: var(--shadow-md);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  z-index: 1000;
  display: none;
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.theme-btn {
  background: var(--primary-soft);
  color: var(--primary);
  border: 1px solid var(--primary-border);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.hero {
  padding: 40px 0 20px;
  text-align: center;
}

.hero h1 {
  font-size: 32px;
  font-weight: 800;
  margin-bottom: 10px;
  color: var(--ink);
}

.hero p {
  font-size: 17px;
  color: var(--ink-soft);
  max-width: 720px;
  margin: 0 auto 30px;
}

.chapters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.chapter-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
  position: relative;
}

.chapter-card.active-chapter:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}

.chapter-card.upcoming {
  opacity: 0.65;
  cursor: default;
}

.chapter-number {
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--primary);
  margin-bottom: 8px;
}

.chapter-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 10px;
}

.chapter-desc {
  font-size: 14px;
  color: var(--ink-soft);
  margin-bottom: 18px;
  flex-grow: 1;
}

.chapter-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 14px;
  border-top: 1px solid var(--card-border);
  font-size: 13px;
  font-weight: 600;
}

.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 700;
}

.status-ready {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
}

.status-upcoming {
  background: var(--tag-bg);
  color: var(--ink-faint);
}

.cta-link {
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}

/* --- Phone portrait -------------------------------------------------------
   The header row put the language picker and theme button off-screen below
   ~600px, and the chapter cards demanded 320px inside a narrower column. */
@media (max-width: 600px) {
  .container { padding: 0 14px; }
  .top-flex { flex-wrap: wrap; gap: 8px 10px; }
  .brand { font-size: 16px; gap: 8px; min-width: 0; }
  .nav-actions { gap: 8px; margin-left: auto; }
  .lang-selector-wrap { min-width: 0; padding: 4px 8px; }
  .lang-select { min-width: 0; max-width: 42vw; font-size: 12px; }
  .theme-btn { padding: 6px 10px; font-size: 12px; }

  .hero { padding: 28px 0 14px; }
  .chapters-grid {
    grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
    gap: 16px;
  }
}

@media (max-width: 430px) {
  .brand > span:not(.brand-badge) { display: none; }
  .theme-btn { padding: 6px 9px; }
  .lang-select { max-width: 55vw; }
  /* Leave the theme label to screen readers - the icon carries it visually. */
  #themeLabel {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
}
