/* ============================================================
   layout.css — Navigace a layout pro Litera v2
   Desktop top navbar + Mobile bottom tab bar
   ============================================================ */

/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--color-surface);
  color: var(--color-text);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* ── Desktop Top Navbar ── */
.top-nav {
  display: none; /* skryto na mobilu */
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--topnav-h);
  background: var(--white);
  border-bottom: 1px solid var(--color-border);
  box-shadow: var(--shadow-sm);
  z-index: 100;
  align-items: center;
  padding: 0 var(--sp-8);
}

.top-nav-logo {
  text-decoration: none;
  display: flex;
  align-items: center;
  white-space: nowrap;
}

.top-nav-logo-img {
  height: 34px;
  width: auto;
  display: block;
}

.top-nav-links {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.top-nav-link {
  text-decoration: none;
  color: var(--blue-500);
  font-weight: 500;
  font-size: var(--text-sm);
  padding: var(--sp-2) var(--sp-4);
  border-radius: var(--radius-full);
  border-bottom: 2px solid transparent;
  transition: color 0.2s, background 0.2s;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

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

.top-nav-link.active {
  background: var(--blue-600);
  color: white;
  border-bottom-color: transparent;
  font-weight: 600;
}

.top-nav-link.active:hover {
  color: white;
}

.top-nav-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

/* ── Streak Badge ── */
.streak-badge-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  color: #c44d00;
  font-weight: 700;
  font-size: var(--text-sm);
  white-space: nowrap;
  user-select: none;
  cursor: pointer;
}

.streak-badge-header {
  display: none;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #fff8e1, #ffe0a0);
  color: #c44d00;
  border: 1.5px solid #ffc107;
  border-radius: var(--radius-full);
  padding: 3px var(--sp-3);
  font-weight: 700;
  font-size: var(--text-xs);
  white-space: nowrap;
  user-select: none;
  cursor: default;
  flex-shrink: 0;
}

/* Na mobilu zobraz streak v audio headeru místo top navu */
@media (max-width: 767px) {
  .streak-badge-header { display: flex; }
}

/* Mobile fixed streak pill (non-audio pages) */
.streak-badge-mobile {
  display: none; /* shown on mobile via media query */
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: 200;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, #fff8e1, #ffe0a0);
  color: #c44d00;
  border: 1.5px solid #ffc107;
  border-radius: var(--radius-full);
  padding: 3px 10px;
  font-weight: 700;
  font-size: 0.8rem;
  cursor: pointer;
  user-select: none;
  pointer-events: auto;
  box-shadow: 0 2px 8px rgba(255, 152, 0, 0.25);
}

@media (max-width: 767px) {
  .streak-badge-mobile { display: flex; }
}

/* ── SVG streak flame ── */
.streak-flame-svg {
  display: inline-block;
  flex-shrink: 0;
  vertical-align: middle;
  transform-origin: 50% 90%;
}
.streak-flame-svg .flame-outer {
  fill: #9ca3af;
  transition: fill 0.5s ease;
}
.streak-flame-svg .flame-mid {
  fill: #c9cdd4;
  transition: fill 0.5s ease;
}
.streak-flame-svg .flame-inner {
  fill: #e2e5e9;
  transition: fill 0.5s ease;
}
.streak-flame-svg.lit .flame-outer { fill: #dc2626; }
.streak-flame-svg.lit .flame-mid   { fill: #f97316; }
.streak-flame-svg.lit .flame-inner { fill: #fde047; }
.streak-flame-svg.lit {
  filter: drop-shadow(0 0 4px rgba(249, 115, 22, 0.6));
}

/* Frozen flame — modrá ledová varianta */
.streak-flame-svg.frozen .flame-outer { fill: #0284c7; }
.streak-flame-svg.frozen .flame-mid   { fill: #38bdf8; }
.streak-flame-svg.frozen .flame-inner { fill: #e0f7ff; }
.streak-flame-svg.frozen {
  filter: drop-shadow(0 0 5px rgba(14, 165, 233, 0.75));
}
.streak-flame-svg.lit.frozen .flame-outer { fill: #0369a1; }
.streak-flame-svg.lit.frozen .flame-mid   { fill: #0ea5e9; }
.streak-flame-svg.lit.frozen .flame-inner { fill: #bae6fd; }
.streak-flame-svg.lit.frozen {
  filter: drop-shadow(0 0 6px rgba(14, 165, 233, 0.85));
}

@keyframes flamePop {
  0%   { transform: scale(1)    rotate(0deg); }
  20%  { transform: scale(1.75) rotate(-14deg); }
  45%  { transform: scale(1.35) rotate(9deg); }
  70%  { transform: scale(1.12) rotate(-3deg); }
  100% { transform: scale(1)    rotate(0deg); }
}

.streak-flame-svg.just-updated {
  animation: flamePop 0.85s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Inactive badge state — no activity completed today */
.streak-badge-nav.streak-inactive,
.streak-badge-header.streak-inactive,
.streak-badge-mobile.streak-inactive {
  color: #6b7280;
}

/* Frozen badge state — freeze k dispozici */
.streak-badge-nav.streak-frozen,
.streak-badge-header.streak-frozen,
.streak-badge-mobile.streak-frozen {
  color: #0284c7;
  border-color: #7dd3fc;
}

/* ── Streak Sheet ── */
.streak-sheet-overlay {
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

/* Desktop — centered modal */
@media (min-width: 600px) {
  .streak-sheet-overlay { align-items: center; }
  .streak-sheet {
    max-width: 380px;
    border-radius: var(--radius-xl) !important;
    animation: modalFadeIn 0.28s ease forwards !important;
  }
  .streak-sheet.out { animation: modalFadeOut 0.2s ease forwards !important; }
  .streak-sheet-handle { display: none; }
}

.streak-sheet {
  background: var(--white);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 480px;
  max-height: 82vh;
  overflow-y: auto;
  padding: var(--sp-3) var(--sp-5) calc(var(--sp-8) + env(safe-area-inset-bottom, 0px));
  animation: sheetSlideUp 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.streak-sheet.out {
  animation: sheetSlideDown 0.25s ease-in forwards;
}

.streak-sheet-handle {
  width: 40px;
  height: 4px;
  background: var(--color-border);
  border-radius: var(--radius-full);
  margin: 0 auto var(--sp-4);
}

.streak-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-4);
}

.streak-sheet-title {
  font-size: var(--text-lg);
  font-weight: 800;
  color: var(--blue-900);
}

.streak-sheet-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--color-border);
  color: var(--color-muted);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.streak-sheet-stats {
  display: flex;
  align-items: center;
  background: var(--blue-50);
  border-radius: var(--radius-lg);
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-5);
}

.streak-stat {
  flex: 1;
  text-align: center;
}

.streak-stat span {
  display: block;
  font-size: var(--text-xs);
  color: var(--color-muted);
  margin-bottom: 2px;
}

.streak-stat strong {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--blue-900);
}

.streak-stat-sep {
  width: 1px;
  height: 32px;
  background: var(--color-border);
  flex-shrink: 0;
}

.streak-stat-clickable {
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: background 0.15s;
}
.streak-stat-clickable:hover { background: rgba(0,0,0,0.05); }

.streak-month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.streak-month-label {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--blue-900);
  text-transform: capitalize;
}

.streak-month-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1.5px solid var(--color-border);
  background: white;
  color: var(--color-muted);
  font-size: 0.8rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, color 0.15s;
}

.streak-month-btn:hover:not(:disabled) {
  border-color: var(--blue-300);
  color: var(--blue-700);
}

.streak-month-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.streak-month-count {
  text-align: center;
  font-size: var(--text-xs);
  color: var(--color-muted);
  margin-top: var(--sp-3);
}

.streak-month-count strong { color: #c44d00; }

/* ── Streak Calendar Grid ── */
.streak-cal-wrap { user-select: none; }

.streak-cal-labels {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  margin-bottom: var(--sp-1);
}

.streak-cal-labels span {
  text-align: center;
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--color-muted);
  text-transform: uppercase;
}

.streak-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

/* Full calendar — sheet */
.streak-cal-full .cal-day {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--color-muted);
}

.streak-cal-full .cal-day.active {
  background: #dc2626;
  color: white;
  font-weight: 700;
}

.streak-cal-full .cal-day.today {
  box-shadow: 0 0 0 2px #1d4ed8;
  color: #1d4ed8;
  font-weight: 700;
}

.streak-cal-full .cal-day.active.today {
  box-shadow: 0 0 0 2px #991b1b;
  color: white;
}

.streak-cal-full .cal-day.future { opacity: 0.2; }

/* Zmražený den — freeze chránil streak */
.streak-cal-full .cal-day.frozen {
  background: #bae6fd;
  color: #0369a1;
  font-weight: 700;
  position: relative;
}
.streak-cal-full .cal-day.frozen::after {
  content: '❄';
  position: absolute;
  bottom: 1px;
  right: 2px;
  font-size: 0.45rem;
  line-height: 1;
  opacity: 0.75;
}
.streak-cal-full .cal-day.frozen.today {
  box-shadow: 0 0 0 2px #0284c7;
}

/* Compact calendar — popup */
.streak-cal-compact .streak-cal-labels span { font-size: 0.5rem; }

.streak-cal-compact .cal-day {
  aspect-ratio: 1;
  border-radius: 50%;
  background: #e5e7eb;
}

.streak-cal-compact .cal-day.active {
  background: #dc2626;
}

.streak-cal-compact .cal-day.today {
  box-shadow: 0 0 0 1.5px #1d4ed8;
}

.streak-cal-compact .cal-day.future {
  background: #f3f4f6;
  opacity: 0.4;
}

.streak-cal-compact .cal-day.frozen {
  background: #7dd3fc;
}

/* Popup cal wrapper */
.streak-popup-cal-wrap {
  width: 100%;
  margin: var(--sp-3) 0 var(--sp-1);
}

/* XP badge v navu */
.xp-badge::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  background: url('../img/coin.svg') center/contain no-repeat;
  flex-shrink: 0;
}
.xp-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: 700;
  font-size: var(--text-sm);
  color: #c44d00;
}

/* ── XP Boost badge (desktop nav + mobile) ── */
@keyframes boostPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.5); }
  50%       { box-shadow: 0 0 0 5px rgba(245, 158, 11, 0); }
}

.xp-boost-badge {
  display: flex;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 99px;
  letter-spacing: 0.02em;
  cursor: default;
  animation: boostPulse 2s ease-in-out infinite;
  white-space: nowrap;
}
.xp-boost-badge .xp-boost-timer {
  font-variant-numeric: tabular-nums;
  font-size: 10px;
  opacity: 0.9;
}

/* Mobile verze — fixed pill vlevo nahoře */
.xp-boost-badge-mobile {
  display: none;
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 200;
  align-items: center;
  gap: 5px;
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: white;
  border-radius: var(--radius-full);
  padding: 4px 12px;
  font-weight: 700;
  font-size: 0.78rem;
  pointer-events: none;
  user-select: none;
  box-shadow: 0 2px 10px rgba(245, 158, 11, 0.4);
  animation: boostPulse 2s ease-in-out infinite;
  font-variant-numeric: tabular-nums;
}

@media (max-width: 767px) {
  .xp-boost-badge-mobile.active { display: flex; }
}

/* ── Streak calendar legenda ── */
.streak-cal-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: var(--sp-3);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--color-border);
  font-size: 0.7rem;
  color: var(--color-muted);
  flex-wrap: wrap;
}

.streak-cal-legend .legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex-shrink: 0;
}
.legend-dot--active { background: #dc2626; }
.legend-dot--frozen { background: #bae6fd; border: 1.5px solid #7dd3fc; position: relative; }
.legend-dot--frozen::after {
  content: '❄';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.45rem;
  color: #0369a1;
}

.top-nav-avatar {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 50%;
  background: var(--blue-100);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.2s;
  overflow: hidden;
  position: relative;
  background-size: cover;
  background-position: center;
}
.top-nav-avatar:hover { transform: scale(1.05); }

/* ── Mobile Bottom Tab Bar ── */
.bottom-nav {
  display: flex; /* visibíní na mobilu */
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--bottomnav-h);
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--white);
  border-top: 1px solid var(--color-border);
  box-shadow: 0 -2px 12px rgba(74, 111, 165, 0.08);
  z-index: 100;
  align-items: center;
  justify-content: space-around;
}

.bottom-nav.hidden {
  transform: translateY(100%);
  transition: transform 0.2s ease;
}

.bottom-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  text-decoration: none;
  color: var(--blue-400);
  padding: var(--sp-2) var(--sp-4);
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-md);
  transition: color 0.15s;
  position: relative;
  background: transparent;
  border: none;
  cursor: pointer;
  font-family: var(--font);
}

.bottom-tab-icon {
  font-size: 1.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  transition: background 0.15s, transform 0.15s;
}

.bottom-tab-label {
  font-size: 0.65rem;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.bottom-tab.active {
  color: var(--blue-700);
}

.bottom-tab.active .bottom-tab-icon {
  background: var(--blue-600);
  color: white;
  transform: scale(1.0);
}

.bottom-tab.active .bottom-tab-label {
  font-weight: 700;
  color: var(--blue-700);
}

/* ── Main Container ── */
.main {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-4);
  /* Na mobilu: prostor dole pro bottom nav */
  padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom) + var(--sp-6));
}

/* Na desktopu: prostor nahoře pro top nav */
@media (min-width: 768px) {
  .top-nav { display: flex; }
  .bottom-nav { display: none; }

  .main {
    padding-top: calc(var(--topnav-h) + var(--sp-8));
    padding-bottom: var(--sp-8);
    padding-left: var(--sp-8);
    padding-right: var(--sp-8);
  }
}

/* ── Section Spacing ── */
.section {
  margin-bottom: var(--sp-5);
}

@media (min-width: 600px) {
  .section {
    margin-bottom: var(--sp-8);
  }
}

.section-title {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--blue-900);
  margin: 0 0 var(--sp-4) 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* ── Back Button (detail pages) ── */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  padding: var(--sp-2) 0;
  margin-bottom: var(--sp-4);
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--font);
  -webkit-tap-highlight-color: transparent;
}
.back-btn:hover { opacity: 0.75; }

/* ── Hero Strip ── */
.hero-strip {
  background: var(--theme-gradient, linear-gradient(135deg, var(--blue-700) 0%, var(--blue-900) 100%));
  border-radius: var(--radius-xl);
  padding: var(--sp-4) var(--sp-4);
  color: var(--white);
  margin-bottom: var(--sp-4);
  position: relative;
  overflow: hidden;
}

@media (min-width: 600px) {
  .hero-strip {
    padding: var(--sp-6) var(--sp-6);
    margin-bottom: var(--sp-6);
  }
}

.hero-strip::before {
  content: '';
  position: absolute;
  top: -50%; right: -20%;
  width: 300px; height: 300px;
  background: rgba(255,255,255,0.05);
  border-radius: 50%;
}

.hero-strip::after {
  content: '';
  position: absolute;
  bottom: -60%; left: -10%;
  width: 200px; height: 200px;
  background: rgba(255,255,255,0.04);
  border-radius: 50%;
}

.hero-greeting {
  font-size: var(--text-sm);
  opacity: 0.8;
  margin-bottom: var(--sp-1);
}

.hero-level {
  font-size: var(--text-xl);
  font-weight: 700;
  margin-bottom: var(--sp-4);
}

.hero-xp-label {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  opacity: 0.8;
  margin-bottom: var(--sp-2);
}

/* ── Streak Toast ──────────────────────────────────────────────────────────── */
.streak-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  width: min(calc(100vw - 2 * var(--sp-4)), 420px);
  background: var(--white);
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.18);
  padding: var(--sp-4);
  z-index: 9500;
  opacity: 0;
  transition: opacity 0.35s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.streak-toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.streak-toast:not(.show) {
  transition: opacity 0.28s ease, transform 0.28s ease;
}

.streak-toast-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.streak-toast-flame {
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  background: #fff7ed;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  color: #f97316;
}

.streak-toast-info {
  flex: 1;
  min-width: 0;
}

.streak-toast-count {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--blue-900);
  line-height: 1.2;
  display: flex;
  align-items: baseline;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.streak-toast-badge {
  font-size: var(--text-xs);
  font-weight: 600;
  color: #f97316;
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: var(--radius-full);
  padding: 1px 8px;
  white-space: nowrap;
}

.streak-toast-msg {
  font-size: var(--text-sm);
  color: var(--color-muted);
  margin-top: 2px;
}

.streak-toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-muted);
  font-size: 0.85rem;
  padding: var(--sp-1);
  line-height: 1;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}
.streak-toast-close:hover { background: var(--color-surface); color: var(--color-text); }

.streak-toast-week {
  display: flex;
  justify-content: space-between;
  gap: var(--sp-1);
  margin-top: var(--sp-3);
  padding-top: var(--sp-3);
  border-top: 1px solid var(--color-border);
}

.streak-toast-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
}

.streak-toast-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-border);
  transition: background 0.2s;
}

.streak-toast-day.active .streak-toast-dot { background: #f97316; }
.streak-toast-day.today  .streak-toast-dot { background: #f97316; box-shadow: 0 0 0 3px #fff7ed; }
.streak-toast-day.future .streak-toast-dot { background: var(--color-surface); border: 1.5px solid var(--color-border); }

.streak-toast-day-label {
  font-size: 0.65rem;
  color: var(--color-muted);
  font-weight: 500;
}
.streak-toast-day.today .streak-toast-day-label { color: #f97316; font-weight: 700; }
