/* ==========================================================================
   Today Page Redesign — GP-DESIGN-002-B1
   Hero card, collapsible habits, timeline, XP bar compact.
   Depends on design-tokens.css (A1) for CSS variables.
   ========================================================================== */

/* --- Hero Card (current lesson) --- */
.today-hero {
  background: linear-gradient(135deg, var(--primary), var(--primary-container));
  border-radius: var(--radius-lg);
  padding: 24px;
  color: var(--on-primary);
  position: relative;
  overflow: hidden;
  margin-bottom: 20px;
  touch-action: pan-y;
}

.today-hero__orb1 {
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  filter: blur(30px);
  pointer-events: none;
}

.today-hero__orb2 {
  position: absolute;
  bottom: -20px;
  left: -20px;
  width: 80px;
  height: 80px;
  background: rgba(255, 224, 135, 0.15);
  border-radius: 50%;
  filter: blur(20px);
  pointer-events: none;
}

.today-hero__label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.9;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.today-hero__label .material-symbols-outlined {
  font-size: 16px;
}

.today-hero__subject {
  font-size: 28px;
  font-weight: 800;
  position: relative;
  z-index: 1;
  margin-bottom: 4px;
}

.today-hero__info {
  font-size: 15px;
  opacity: 0.9;
  position: relative;
  z-index: 1;
  margin-bottom: 16px;
}

/* Glassmorphic pill */
.today-hero__pill {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 999px;
  padding: 10px 20px;
  position: relative;
  z-index: 1;
}

.today-hero__pill-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.8;
}

.today-hero__pill-time {
  font-size: 20px;
  font-weight: 800;
}

.today-hero__pill-sep {
  width: 1px;
  height: 28px;
  background: rgba(255, 255, 255, 0.3);
}

.today-hero__pill .material-symbols-outlined {
  font-size: 24px;
}

/* --- Section Header --- */
.today-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.today-section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--on-surface);
}

.today-section-badge {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
}

/* --- DayScrollStrip --- */
.day-scroll-container {
  background: var(--surface-container-lowest, #fff);
  padding: 12px 0 4px;
  border-bottom: 2px solid var(--surface-container, #eaeef0);
  position: sticky;
  top: 0;
  z-index: 10;
  -webkit-transform: translateZ(0);
  transform: translateZ(0);
}
.day-scroll-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-x;
  padding: 4px 16px;
  scrollbar-width: none;
}
.day-scroll-strip::-webkit-scrollbar { display: none; }
.day-scroll-cell {
  flex: 0 0 auto;
  width: 56px;
  height: 72px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  scroll-snap-align: center;
  transition: all 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
  position: relative;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-width: 56px;
  min-height: 56px;
}
.day-scroll-cell[role="button"] { cursor: pointer; }
.day-scroll-cell:active { transform: scale(0.93); }
.day-scroll-cell--default {
  background: var(--surface-container, #eaeef0);
  color: var(--on-surface-variant, #596062);
}
.day-scroll-cell--today {
  background: var(--primary, #006498);
  color: var(--on-primary, #f6f9ff);
  box-shadow: 0 4px 16px rgba(0, 100, 152, 0.35);
  font-weight: 700;
}
.day-scroll-cell--selected {
  background: var(--surface-container-lowest, #fff);
  color: var(--primary, #006498);
  outline: 3px solid var(--primary, #006498);
  outline-offset: -3px;
  font-weight: 700;
}
.day-scroll-cell--past-active {
  background: var(--surface-container, #eaeef0);
  color: var(--on-surface, #2d3435);
  border: 2px solid var(--outline-variant, #acb3b5);
}
.day-scroll-cell--past-active:hover {
  border-color: var(--primary-light, #85c7ff);
  background: var(--hover-highlight, #eef6ff);
}
.day-scroll-cell--past-locked {
  background: var(--surface-container, #eaeef0);
  color: var(--outline-variant, #acb3b5);
  opacity: 0.5;
  pointer-events: none;
}
.day-scroll-cell--future {
  background: var(--surface-container, #eaeef0);
  color: var(--outline-variant, #acb3b5);
  opacity: 0.4;
  pointer-events: none;
}
.day-scroll-cell__weekday {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.day-scroll-cell__number {
  font-size: 20px;
  font-weight: 700;
  line-height: 1.1;
}
.day-scroll-cell__dot { width: 6px; height: 6px; border-radius: 50%; margin-top: 3px; }
.day-scroll-cell__dot--none { background: transparent; }
.day-scroll-cell__dot--partial { background: var(--xp-gold, #F59E0B); }
.day-scroll-cell__dot--full { background: var(--tertiary, #006d43); }
.day-scroll-cell--today .day-scroll-cell__dot--partial { background: var(--xp-gold, #F59E0B); }
.day-scroll-cell--today .day-scroll-cell__dot--full { background: var(--tertiary-container, #9ffcc4); }
@media (prefers-reduced-motion: reduce) {
  .day-scroll-cell { transition: none; }
  .day-scroll-cell:active { transform: none; }
  .day-scroll-strip { scroll-snap-type: none; scroll-behavior: auto; }
}
.day-scroll-legend {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 6px 16px 2px;
  font-size: 11px;
  color: var(--on-surface-variant, #596062);
}
.day-scroll-legend-item { display: flex; align-items: center; gap: 4px; }
.day-scroll-legend-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.day-scroll-legend-dot--full { background: var(--tertiary, #006d43); }
.day-scroll-legend-dot--partial { background: var(--xp-gold, #F59E0B); }
.day-scroll-legend-dot--none { background: transparent; border: 1px solid var(--outline-variant, #acb3b5); }
.day-scroll-date-label {
  text-align: center;
  padding: 10px 16px 4px;
  font-size: 14px;
  color: var(--on-surface-variant, #596062);
  font-weight: 600;
}
.day-scroll-date-label strong { color: var(--primary, #006498); }
.day-scroll-retro-badge {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-size: 12px;
  color: var(--on-surface-variant, #596062);
  background: var(--surface-container, #eaeef0);
  padding: 4px 14px;
  border-radius: 12px;
  margin: 6px auto 0;
  width: fit-content;
}
.day-scroll-retro-badge.visible { display: flex; }
.day-scroll-hint {
  display: none;
  text-align: center;
  padding: 4px 16px 8px;
  font-size: 13px;
  color: var(--outline, #757c7e);
  font-style: italic;
}
.day-scroll-hint.visible { display: block; }

/* --- Collapsible Habit Groups --- */
.today-habit-groups {
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.today-habit-group {
  background: var(--surface-container-lowest);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.today-habit-group__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 56px;
}

.today-habit-group__header:active {
  background: var(--surface-container-low);
}

.today-habit-group__left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.today-habit-group__icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.today-habit-group__icon .material-symbols-outlined {
  font-size: 20px;
}

.today-habit-group__name {
  font-size: 15px;
  font-weight: 700;
  color: var(--on-surface);
}

.today-habit-group__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.today-habit-group__count {
  font-size: 12px;
  font-weight: 700;
  color: var(--on-surface-variant);
  background: var(--surface-container);
  padding: 2px 8px;
  border-radius: 999px;
}

.today-habit-group__count.all-done {
  background: var(--tertiary-container);
  color: var(--on-tertiary-container);
}

.today-habit-group__arrow {
  font-size: 20px;
  color: var(--outline);
  transition: transform 0.25s ease;
}

.today-habit-group.open .today-habit-group__arrow {
  transform: rotate(180deg);
}

/* Collapsible body */
.today-habit-group__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.today-habit-group.open .today-habit-group__body {
  max-height: 800px;
}

/* Habit list inside group */
.today-habit-list {
  padding: 0 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Habit item — container does NOT change on done/active */
.today-habit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface-container-low);
  cursor: pointer;
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
  min-height: 56px;
}

.today-habit-item:active {
  transform: scale(0.98);
}

/* Done state: only content changes, container stays the same */
.today-habit-item.done .today-habit-item__name {
  opacity: 0.7;
  text-decoration: line-through;
  color: var(--on-surface-variant);
}

/* Check circle */
.today-habit-item__check {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.today-habit-item__check .material-symbols-outlined {
  font-size: 20px;
}

.today-habit-item:not(.done) .today-habit-item__check {
  background: var(--surface-container-high);
}

.today-habit-item:not(.done) .today-habit-item__check .material-symbols-outlined {
  color: var(--outline);
}

.today-habit-item.done .today-habit-item__check {
  background: var(--tertiary-container);
}

.today-habit-item.done .today-habit-item__check .material-symbols-outlined {
  color: var(--tertiary);
}

.today-habit-item__name {
  font-size: 14px;
  font-weight: 600;
  color: var(--on-surface);
  flex: 1;
  min-width: 0;
}

/* Inline streak counter — visible always (incl. streak=0 baseline) */
.today-habit-item__streak {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-width: 44px;
  min-height: 28px;
  padding: 4px 8px;
  margin-left: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface-variant);
  background: var(--surface-container-high);
  border-radius: 12px;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background 0.2s, color 0.2s, transform 0.2s;
}

.today-habit-item__streak.streak-active {
  color: #ff7043;
  background: rgba(255, 112, 67, 0.12);
}

.today-habit-item__streak.streak-bump {
  animation: streak-bump 0.4s ease-out;
}

@keyframes streak-bump {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.18); }
  100% { transform: scale(1); }
}

/* --- Timeline (Schedule) --- */
.today-timeline {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 20px;
}

.today-timeline-item {
  display: flex;
  gap: 12px;
  position: relative;
}

.today-timeline-item__left {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 40px;
  flex-shrink: 0;
}

.today-timeline-item__dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--surface-container-high);
  border: 3px solid var(--surface-container);
  position: relative;
  z-index: 2;
  margin-top: 20px;
}

.today-timeline-item__dot.active {
  background: var(--primary);
  border-color: var(--primary-container);
}

.today-timeline-item__dot.past {
  background: var(--outline-variant);
  border-color: var(--surface-container);
}

.today-timeline-item__line {
  width: 2px;
  flex: 1;
  background: var(--surface-container-high);
  margin: 0 auto;
}

/* Timeline card — container does NOT change */
.today-timeline-card {
  flex: 1;
  background: var(--surface-container-lowest);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 12px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.today-timeline-card.current {
  box-shadow: 0 0 0 2px rgba(0, 100, 152, 0.15), var(--shadow);
}

/* Muted past cards — only content changes */
.today-timeline-card.past .today-subject-name,
.today-timeline-card.past .today-subject-time,
.today-timeline-card.past .today-subject-room {
  opacity: 0.5;
}

.today-timeline-card.past .today-subject-icon {
  opacity: 0.5;
}

.today-subject-icon {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.today-subject-icon .material-symbols-outlined {
  font-size: 24px;
}

.today-subject-time {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 2px;
}

.today-subject-name {
  font-size: 17px;
  font-weight: 700;
  color: var(--on-surface);
}

.today-subject-room {
  font-size: 13px;
  color: var(--on-surface-variant);
}

/* --- Section Link --- */
.today-section-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.today-section-link:active {
  opacity: 0.7;
}

/* --- Tomorrow (Collapsible Timeline) --- */
.today-tomorrow {
  margin-bottom: 20px;
  background: var(--surface-container-lowest);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.today-tomorrow__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  min-height: 56px;
}

.today-tomorrow__header:active {
  background: var(--surface-container-low);
}

.today-tomorrow__left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.today-tomorrow__left .material-symbols-outlined {
  font-size: 20px;
  color: var(--primary);
}

.today-tomorrow__title {
  font-size: 15px;
  font-weight: 700;
  color: var(--on-surface);
}

.today-tomorrow__arrow {
  font-size: 20px;
  color: var(--outline);
  transition: transform 0.25s ease;
}

.today-tomorrow.open .today-tomorrow__arrow {
  transform: rotate(180deg);
}

.today-tomorrow__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.today-tomorrow.open .today-tomorrow__body {
  max-height: 1200px;
}

.today-tomorrow__body .today-timeline {
  padding: 0 12px 12px;
}

/* --- XP Bar Compact --- */
.today-xp-card {
  background: var(--surface-container-lowest);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 12px;
}

.today-xp-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--on-surface);
  white-space: nowrap;
}

.today-xp-bar-outer {
  flex: 1;
  height: 10px;
  background: var(--surface-container);
  border-radius: 5px;
  overflow: hidden;
}

.today-xp-bar-inner {
  height: 100%;
  background: linear-gradient(90deg, var(--xp-gold), #FBBF24);
  border-radius: 5px;
  position: relative;
  transition: width 0.5s ease;
}

.today-xp-bar-inner::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 4px;
  right: 4px;
  height: 3px;
  background: rgba(255, 255, 255, 0.4);
  border-radius: 2px;
}

.today-xp-nums {
  font-size: 12px;
  font-weight: 600;
  color: var(--on-surface-variant);
  white-space: nowrap;
}

/* --- Fade-in animation --- */
@keyframes todayFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

#view-day .today-hero,
#view-day .today-section-header,
#view-day .today-habit-groups,
#view-day .today-timeline,
#view-day .today-xp-card {
  animation: todayFadeIn 0.3s ease forwards;
}

#view-day .today-habit-groups { animation-delay: 0.05s; }
#view-day .today-timeline { animation-delay: 0.1s; }
#view-day .today-xp-card { animation-delay: 0.15s; }

/* --- Phase 0 Shop Promo (motivation cliff fix) --- */

.shop-promo-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: linear-gradient(135deg, var(--surface-container-high), var(--surface-container));
  border-radius: var(--radius-lg, 16px);
  margin-bottom: 20px;
  min-height: 64px;
}

.shop-promo-card__icon {
  font-size: 32px;
  flex-shrink: 0;
}

.shop-promo-card__body {
  flex: 1;
  min-width: 0;
}

.shop-promo-card__name {
  font-size: 15px;
  font-weight: 600;
  color: var(--on-surface);
}

.shop-promo-card__price {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  margin-top: 2px;
}

.shop-promo-card__buy {
  min-height: 56px;
  min-width: 96px;
  padding: 0 16px;
  border: none;
  border-radius: 16px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s;
}

.shop-promo-card__buy:active {
  transform: scale(0.96);
}

.shop-promo-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  animation: fade-in 0.2s ease-out;
}

.shop-promo-overlay__content {
  background: var(--surface, #fff);
  padding: 24px 28px 20px;
  border-radius: 20px;
  text-align: center;
  max-width: 320px;
  width: calc(100% - 48px);
}

.shop-promo-overlay__emoji {
  font-size: 56px;
  line-height: 1;
}

.shop-promo-overlay__title {
  font-size: 22px;
  font-weight: 700;
  color: var(--on-surface);
  margin-top: 8px;
}

.shop-promo-overlay__sub {
  font-size: 15px;
  color: var(--on-surface-variant);
  margin-top: 4px;
  margin-bottom: 16px;
}

.shop-promo-overlay__close {
  min-height: 56px;
  width: 100%;
  border: none;
  border-radius: 16px;
  background: var(--primary);
  color: var(--on-primary);
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
}

.shop-promo-error {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 59, 48, 0.95);
  color: #fff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  z-index: 9999;
  max-width: calc(100% - 32px);
  text-align: center;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}
