/* ==========================================================================
   Stitch Homework Redesign — GP-DESIGN-002-B2
   Bento cards, glassmorphic filter chips, progress orb, FAB.
   Depends on design-tokens.css (A1) for CSS variables.
   ========================================================================== */

/* --- Page Header --- */
.hw-page-subtitle {
  font-size: 11px;
  font-weight: 700;
  color: var(--on-surface-variant);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 4px;
}

.hw-page-title {
  font-family: 'Nunito', sans-serif;
  font-size: 26px;
  font-weight: 800;
  color: var(--on-surface);
  margin-bottom: 16px;
}

/* --- Filter Chips (glassmorphic pills) --- */
.hw-stitch-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}

.hw-stitch-filters::-webkit-scrollbar {
  display: none;
}

/* Fade hint for narrow screens (iPhone SE) when chips overflow */
@media (max-width: 374px) {
  .hw-stitch-filters {
    mask-image: linear-gradient(to right, black 90%, transparent 100%);
    -webkit-mask-image: linear-gradient(to right, black 90%, transparent 100%);
  }
}

.hw-filter-chip {
  padding: 10px 20px;
  border-radius: 999px;
  border: none;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
  -webkit-tap-highlight-color: transparent;
  min-height: 56px;
}

.hw-filter-chip.active {
  background: var(--primary);
  color: var(--on-primary);
  box-shadow: 0 4px 12px rgba(0, 100, 152, 0.2);
}

.hw-filter-chip:not(.active) {
  background: var(--surface-container-high);
  color: var(--on-surface-variant);
}

.hw-filter-chip:active {
  transform: scale(0.95);
}

/* --- Hide-done toggle --- */
.hw-hide-done-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.hw-hide-done-toggle input {
  display: none;
}
.hw-hide-done-slider {
  width: 40px;
  height: 22px;
  background: var(--surface-container-high);
  border-radius: 11px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.hw-hide-done-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.hw-hide-done-toggle input:checked + .hw-hide-done-slider {
  background: var(--primary);
}
.hw-hide-done-toggle input:checked + .hw-hide-done-slider::after {
  transform: translateX(18px);
}
.hw-hide-done-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--on-surface-variant);
  font-family: 'Nunito', sans-serif;
}

/* --- Progress Card --- */
.hw-progress-card {
  background: linear-gradient(135deg, var(--primary), var(--primary-dim));
  border-radius: var(--radius-lg);
  padding: 20px;
  color: var(--on-primary);
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
}

.hw-progress-orb {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.hw-progress-orb svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.hw-progress-orb-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.hw-progress-orb-pct {
  font-size: 16px;
  font-weight: 800;
}

.hw-progress-orb-label {
  font-size: 8px;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.8;
}

.hw-progress-info h4 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 4px;
}

.hw-progress-info p {
  font-size: 13px;
  opacity: 0.8;
}

.hw-progress-pills {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.hw-progress-pill {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
}

/* --- Bento HW Cards --- */
.hw-bento-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.hw-bento-card {
  background: var(--surface-container-lowest);
  border-radius: var(--radius-lg);
  padding: 0;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0;
  position: relative;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
}

.hw-bento-card::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 6px;
}

/* Container does NOT change for done state — only content differs */
.hw-bento-card.done {
  /* box-shadow, ::before opacity remain unchanged */
}

.hw-bento-card.done::before {
  /* opacity stays 1 */
}

/* --- Card Inner Structure --- */
.hw-bento-card-inner {
  position: relative;
  z-index: 1;
  background: inherit;
  border-radius: inherit;
  transform: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}

.hw-bento-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.hw-subject-chip {
  padding: 4px 14px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.hw-bento-due {
  font-size: 12px;
  font-weight: 700;
  color: var(--on-surface-variant);
  display: flex;
  align-items: center;
  gap: 4px;
}

.hw-bento-due.urgent {
  color: var(--error);
}

.hw-bento-due .material-symbols-outlined {
  font-size: 14px;
}

.hw-bento-title {
  font-family: 'Nunito', sans-serif;
  font-size: 17px;
  font-weight: 700;
  color: var(--on-surface);
}

.hw-bento-card.done .hw-bento-title {
  text-decoration: line-through;
  color: var(--on-surface-variant);
}

.hw-bento-desc {
  font-size: 13px;
  color: var(--on-surface-variant);
  line-height: 1.5;
}

.hw-bento-card.done .hw-bento-desc {
  opacity: 0.6;
  font-style: italic;
}

.hw-bento-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hw-bento-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-container-low);
  padding: 8px 16px;
  border-radius: 999px;
  border: none;
  font-family: 'Nunito', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: var(--on-surface);
  cursor: pointer;
  transition: all 0.15s;
  min-height: 56px;
  -webkit-tap-highlight-color: transparent;
}

.hw-bento-btn:active {
  transform: scale(0.95);
  background: var(--surface-container-high);
}

.hw-bento-btn .material-symbols-outlined {
  font-size: 18px;
}

.hw-bento-subject-icon .material-symbols-outlined {
  font-size: 20px;
}

/* --- Done Badge --- */
.hw-done-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--tertiary);
  color: var(--on-primary);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
}

.hw-done-badge .material-symbols-outlined {
  font-size: 12px;
}

.hw-done-xp {
  display: flex;
  align-items: center;
  gap: 6px;
}

.hw-done-xp .material-symbols-outlined {
  font-size: 18px;
}

.hw-done-xp-text {
  font-size: 12px;
  font-weight: 700;
  color: var(--tertiary);
}

/* --- HW Type Badge (x3 XP) --- */
.hw-type-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, var(--xp-gold), var(--cta));
  color: #fff;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  text-transform: uppercase;
  margin-left: 8px;
}

/* --- Quick Add --- */
.hw-quick-add {
  background: var(--surface-container-high);
  opacity: 0.5;
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: opacity 0.2s;
  -webkit-tap-highlight-color: transparent;
  min-height: 56px;
}

.hw-quick-add:active {
  opacity: 0.7;
}

.hw-quick-add-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--primary-container);
  display: flex;
  align-items: center;
  justify-content: center;
}

.hw-quick-add-icon .material-symbols-outlined {
  font-size: 24px;
  color: var(--primary);
}

.hw-quick-add-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--on-surface-variant);
}

/* --- FAB (Floating Action Button) --- */
.hw-fab {
  position: fixed;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 100px);
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--primary-container));
  color: var(--on-primary);
  border: none;
  box-shadow: 0 8px 24px rgba(0, 100, 152, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 90;
  transition: transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.hw-fab:active {
  transform: scale(0.9);
}

.hw-fab .material-symbols-outlined {
  font-size: 28px;
  font-variation-settings: 'wght' 600;
}

/* --- Attachment dropdown (reusing existing logic, Stitch styling) --- */
.hw-bento-card .hw-att-dropdown {
  width: 100%;
  overflow: hidden;
  transition: max-height 0.2s ease-out, opacity 0.2s ease-out;
}

.hw-bento-card .hw-att-dropdown:not(.hidden) {
  padding-top: 8px;
  border-top: 1px solid var(--outline-variant);
  margin-top: 8px;
}

/* --- Action Panel (swipe-to-reveal, reusing existing logic) --- */
.hw-bento-card .hw-action-panel {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  display: flex;
  z-index: 0;
}

.hw-bento-card .hw-action-btn {
  min-width: 72px;
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  border: none;
  color: #fff;
  cursor: pointer;
  padding: 0 8px;
}

.hw-bento-card .hw-action-btn.edit { background: #3b82f6; }
.hw-bento-card .hw-action-btn.delete { background: #ef4444; }

/* --- Recurring card progress (Stitch) --- */
.hw-bento-card .hw-progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}

.hw-bento-card .hw-progress-bar {
  flex: 1;
  height: 6px;
  background: var(--surface-container-high);
  border-radius: 999px;
  overflow: hidden;
}

.hw-bento-card .hw-progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.3s ease;
}

.hw-bento-card .hw-progress-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--on-surface-variant);
  white-space: nowrap;
}

.hw-bento-card .hw-streak {
  color: var(--cta);
}

/* --- Recurring badge --- */
.hw-recurring-icon {
  font-size: 14px;
  margin-right: 4px;
}

/* --- Content area override for HW tab --- */
.hw-stitch-content {
  padding: 16px 20px 100px;
  background: var(--surface-container);
  min-height: 100%;
}

/* --- Animations --- */
@keyframes hwFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.hw-bento-grid > * {
  animation: hwFadeIn 0.3s ease forwards;
}

/* --- Empty state Stitch override --- */
.hw-stitch-empty {
  text-align: center;
  padding: 40px 20px;
}

.hw-stitch-empty .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
}

.hw-stitch-empty .empty-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--on-surface-variant);
  margin-bottom: 16px;
}

.hw-stitch-empty-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-container));
  color: var(--on-primary);
  border-radius: 999px;
  font-family: 'Nunito', sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  box-shadow: 0 4px 12px rgba(0, 100, 152, 0.2);
  min-height: 56px;
  -webkit-tap-highlight-color: transparent;
}

.hw-stitch-empty-cta:active {
  transform: scale(0.95);
}
