/* Home layout and category grid */
body.on-home {
  --base-font: 18px;
  font-size: 18px;
}

/* Hero Section */
.hero-section {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  backdrop-filter: blur(10px);
  border-radius: 16px;
  padding: 1.2rem;
  margin: 0.2rem 0 0.8rem;
  text-align: center;
  position: relative;
  overflow: hidden;
  animation: heroEntrance 0.8s ease-out;
}

.hero-section::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
  animation: shimmer 3s ease-in-out infinite;
}

@keyframes heroEntrance {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.hero-welcome {
  font-size: 2rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  background: linear-gradient(45deg, var(--btn-color), #FF6B6B);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.hero-subtitle {
  font-size: 1.1rem;
  opacity: 0.8;
  margin-bottom: 0.8rem;
}

.daily-fact-card {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0.8rem;
  margin: 0.6rem 0;
  position: relative;
  animation: factSlideIn 0.6s ease-out 0.3s both;
}

@keyframes factSlideIn {
  0% {
    opacity: 0;
    transform: translateX(-20px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

.fact-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
  font-weight: bold;
  font-size: 1.2rem;
}

.fact-icon {
  font-size: 1.5rem;
  animation: factIconPulse 2s ease-in-out infinite;
}

@keyframes factIconPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.fact-content {
  font-size: 1rem;
  line-height: 1.5;
  font-style: italic;
}

.hero-stats {
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  margin-top: 0.8rem;
}

/* Current Streak Card */
.current-streak-card {
  background: linear-gradient(135deg, rgba(255, 100, 0, 0.1), rgba(255, 140, 0, 0.05));
  border: 1px solid rgba(255, 140, 0, 0.3);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  animation: streakPulse 2s ease-in-out infinite;
}

@keyframes streakPulse {
  0%, 100% { 
    box-shadow: 0 0 10px rgba(255, 140, 0, 0.3);
  }
  50% { 
    box-shadow: 0 0 20px rgba(255, 140, 0, 0.5);
  }
}

.streak-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.streak-fire {
  font-size: 1.2rem;
  animation: fireFlicker 1.5s ease-in-out infinite alternate;
}

@keyframes fireFlicker {
  0% { transform: scale(1) rotate(-2deg); }
  100% { transform: scale(1.1) rotate(2deg); }
}

.streak-text {
  font-weight: bold;
  font-size: 1rem;
}

.streak-value {
  font-size: 2rem;
  font-weight: bold;
  color: #FF8C00;
  margin-bottom: 0.25rem;
}

.streak-encourage {
  font-size: 0.9rem;
  opacity: 0.8;
  font-style: italic;
}

/* Achievement Showcase */
.achievement-showcase {
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 165, 0, 0.05));
  border: 1px solid rgba(255, 215, 0, 0.3);
  border-radius: 12px;
  padding: 1rem;
  animation: achievementGlow 3s ease-in-out infinite;
}

@keyframes achievementGlow {
  0%, 100% { 
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.2);
  }
  50% { 
    box-shadow: 0 0 15px rgba(255, 215, 0, 0.4);
  }
}

.achievement-title {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: bold;
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

.achievement-icon {
  font-size: 1.2rem;
  animation: trophyBounce 2s ease-in-out infinite;
}

@keyframes trophyBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}

.achievement-grid-mini {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.achievement-badge-mini {
  background: linear-gradient(45deg, #FFD700, #FFA500);
  color: #333;
  padding: 0.25rem 0.5rem;
  border-radius: 15px;
  font-size: 0.75rem;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
  animation: badgeEntrance 0.5s ease-out both;
}

@keyframes badgeEntrance {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(-10deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

/* Stats Grid */
.stats-grid {
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.stat-item {
  text-align: center;
  animation: statFadeIn 0.4s ease-out both;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

@keyframes statFadeIn {
  0% {
    opacity: 0;
    transform: translateY(10px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.stat-icon {
  font-size: 1.2rem;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: bold;
  color: var(--btn-color);
  display: block;
}

.stat-label {
  font-size: 0.9rem;
  opacity: 0.7;
}

/* Mobile hero optimizations */
@media (max-width: 600px) {
  .hero-section {
    padding: 0.8rem;
    margin: 0.1rem 0 0.6rem;
  }
  
  .hero-welcome {
    font-size: 1.5rem;
  }
  
  .hero-subtitle {
    font-size: 1rem;
    margin-bottom: 0.6rem;
  }
  
  .daily-fact-card {
    padding: 0.6rem;
    margin: 0.4rem 0;
  }
  
  .hero-stats {
    gap: 0.6rem;
    margin-top: 0.6rem;
  }
  
  .settings-card {
    margin: 0.4rem 0;
    padding: 0.8rem;
  }
  
  .custom-wrapper {
    margin: 0 auto 0.4rem;
    padding: 0.4rem;
  }
}

.category-grid {
  width: 100%;
  display: grid;
  gap: 0.5rem;
  row-gap: calc(0.5rem + 5px);
  grid-template-columns: repeat(auto-fit, minmax(calc(var(--base-font) * 8.9), 1fr));
  justify-content: center;
  margin-bottom: 12px;
}

.category-section details {
  margin-bottom: 0.6rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.03));
  backdrop-filter: blur(8px);
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  overflow: hidden;
  animation: sectionEntrance 0.6s ease-out;
}

@keyframes sectionEntrance {
  0% {
    opacity: 0;
    transform: translateY(15px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

.category-section summary {
  cursor: pointer;
  font-weight: bold;
  margin: 0;
  padding: 0.6rem 0.8rem;
  background: rgba(255, 255, 255, 0.05);
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.category-section summary:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateX(5px);
}

.category-section summary::marker {
  display: none;
}

.category-section summary::before {
  content: '▶';
  font-size: 0.8rem;
  transition: transform 0.3s ease;
  color: var(--btn-color);
}

.category-section details[open] summary::before {
  transform: rotate(90deg);
}

.category-section details[open] summary {
  background: rgba(255, 255, 255, 0.1);
}

.category-section .category-grid {
  padding: 0.6rem 0.8rem 0.8rem;
  background: rgba(255, 255, 255, 0.02);
}

.num-wrapper {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  overflow: visible;
  gap: 0.75rem;
  padding-top: 5px;
  padding-bottom: 5px;
  margin-top: 30px;
  margin-bottom: 1.5rem;
  width: 100%;
  flex-direction: row !important;
  align-items: center;
}

.num-wrapper label.pill-radio {
  flex: 0 1 auto;
  white-space: nowrap;
  font-size: clamp(0.9rem, 2.5vw, 1rem);
}

.num-wrapper p {
  margin: 0 0 0.5rem;
  text-align: center;
  width: 100%;
  flex-basis: 100%;
}

.home-settings-grid {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr 1fr;
  gap: 0.75rem;
  justify-items: stretch;
  width: 100%;
}

.mode-wrapper {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 1rem;
  padding: 0.5rem;
}

.custom-wrapper {
  margin: 0 auto 0.6rem;
  display: flex;
  gap: 0.5rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  animation: customInputEntrance 0.7s ease-out;
}

@keyframes customInputEntrance {
  0% {
    opacity: 0;
    transform: translateX(-20px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

.custom-wrapper input {
  flex: 1 1 auto;
  min-width: 0;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

.custom-wrapper input:focus {
  border-color: rgba(255, 255, 255, 0.6);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.15);
}

.custom-wrapper .pill-btn {
  flex: 0 0 auto;
  background: var(--btn-color);
  border: 1px solid rgba(255, 255, 255, 0.3);
  transition: all 0.3s ease;
}

.custom-wrapper .pill-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.num-wrapper label,
.mode-wrapper label,
.style-wrapper label {
  margin: 0 0.5rem;
}

.fun-fact {
  margin: 0.375rem auto 12px;
  text-align: center;
}

body:not(.settings-root) #font-size-section {
  display: none !important;
}

.category-grid .pill-btn {
  width: 100%;
  font-size: var(--base-font);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
  animation: categoryEntrance 0.5s ease-out;
}

.category-grid .pill-btn {
  margin: 0em 0 !important;
  min-height: 48px;
  border-radius: 12px !important;
  background: var(--btn-color);
  border: 2px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  color: #fff;
  font-weight: 600;
}

.category-grid .pill-btn::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s ease;
}

.category-grid .pill-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
  border-color: rgba(255, 255, 255, 0.6);
  background: color-mix(in srgb, var(--btn-color) 85%, white 15%);
}

.category-grid .pill-btn:hover::before {
  left: 100%;
}

.category-grid .pill-btn:active {
  transform: translateY(-1px) scale(0.98);
  transition: transform 0.1s ease;
}

@keyframes categoryEntrance {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.9);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Staggered animation for category buttons */
.category-grid .pill-btn:nth-child(1) { animation-delay: 0.1s; }
.category-grid .pill-btn:nth-child(2) { animation-delay: 0.15s; }
.category-grid .pill-btn:nth-child(3) { animation-delay: 0.2s; }
.category-grid .pill-btn:nth-child(4) { animation-delay: 0.25s; }
.category-grid .pill-btn:nth-child(5) { animation-delay: 0.3s; }
.category-grid .pill-btn:nth-child(6) { animation-delay: 0.35s; }
.category-grid .pill-btn:nth-child(7) { animation-delay: 0.4s; }
.category-grid .pill-btn:nth-child(8) { animation-delay: 0.45s; }
.category-grid .pill-btn:nth-child(9) { animation-delay: 0.5s; }
.category-grid .pill-btn:nth-child(10) { animation-delay: 0.55s; }

.style-wrapper {
  margin: 1rem auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
  text-align: center;
}

.style-wrapper p {
  margin-bottom: 0.5rem;
  font-weight: bold;
}

/* Front page settings card redesign */
:root {
  --pill-checked-bg: #c73737;
  --pill-border-color: #ccc;
}

.settings-card {
  max-width: 100%;
  width: 100%;
  margin: 0.6rem 0;
  border-radius: 1.25rem;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
  padding: 1rem;
  position: relative;
  overflow: hidden;
  animation: cardEntrance 0.6s ease-out;
}

.settings-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  animation: cardShimmer 2s ease-in-out infinite;
}

@keyframes cardEntrance {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes cardShimmer {
  0% { left: -100%; }
  100% { left: 100%; }
}

.settings-card h2 {
  margin: 0 0 0.5rem;
  text-align: center;
}

.settings-card h3 {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.settings-card .mode-wrapper,
.settings-card .style-wrapper {
  display: flex;
  justify-content: center;
  margin: 0.25rem 0;
  padding: 0;
  gap: 0.5rem;
}

.settings-card .mode-wrapper {
  flex-wrap: wrap;
}

.settings-card .style-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.style-wrapper-row-2 {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
}

.settings-card .num-wrapper {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr;
  grid-template-rows: auto auto;
  justify-items: center;
  margin: 0.25rem 0;
  padding: 0;
  gap: 0.4rem;
  overflow: visible;
}

.settings-card .num-wrapper label.pill-radio:nth-child(1) {
  grid-column: 1;
  grid-row: 1;
}

.settings-card .num-wrapper label.pill-radio:nth-child(2) {
  grid-column: 3;
  grid-row: 1;
}

.settings-card .num-wrapper label.pill-radio:nth-child(3) {
  grid-column: 5;
  grid-row: 1;
}

.settings-card .num-wrapper label.pill-radio:nth-child(4) {
  grid-column: 2;
  grid-row: 2;
}

.settings-card .num-wrapper label.pill-radio:nth-child(5) {
  grid-column: 4;
  grid-row: 2;
}

.pill-radio {
  display: inline-block;
  padding: 0.3rem 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(5px);
  color: #111;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  animation: pillEntrance 0.4s ease-out;
}

.pill-radio::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  transform: translate(-50%, -50%);
  transition: width 0.3s ease, height 0.3s ease;
  pointer-events: none;
}

.pill-radio:hover::before {
  width: 100px;
  height: 100px;
}

.pill-radio:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-color: rgba(255, 255, 255, 0.5);
}

.pill-radio input {
  display: none;
}

.pill-radio.selected {
  background: var(--pill-checked-bg);
  border-color: var(--pill-checked-bg);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
  animation: pillSelect 0.3s ease-out;
}

@keyframes pillEntrance {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes pillSelect {
  0% { transform: translateY(-1px) scale(1); }
  50% { transform: translateY(-3px) scale(1.05); }
  100% { transform: translateY(-2px) scale(1); }
}

@media (min-width: 600px) {
  .home-settings-grid {
    grid-template-columns: 0.8fr 1.2fr 1fr;
  }

  .settings-card .num-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 0.2rem;
    overflow: visible;
  }

  .settings-card .num-wrapper label.pill-radio {
    justify-self: center;
  }
}

@media (max-width: 599px) {
  .home-settings-grid {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }
  
  .settings-card .num-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.35rem;
  }
  
  .settings-card .style-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
  }
  
  .style-wrapper-row-2 {
    display: contents;
  }
}
