/* ================================================================
   HOME.CSS — Home / dashboard page
   Part of the RustyBlade BootCamp stylesheet, split for maintainability.
   Load order within the "pages" group: track, settings, admin, shared,
   home, login, logbook (verified against internal duplicate-selector
   overrides before this split was made). Loads after components.css,
   before utilities.css, in the overall 6-group sequence.
   ================================================================ */

/* ================================================================
   SECTION 9: HOME / DASHBOARD PAGE
   ================================================================ */

.greeting {
  font-weight: 700;
  font-size: 1.375rem;
  margin-bottom: 1px;
  font-family: var(--font);
}
.sub-greeting {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.home-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
}
.home-card {
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  text-align: center;
  transition: 0.2s;
  box-shadow: var(--shadow-sm);
  border-top: 2px solid var(--accent-soft);
  min-width: 0; /* FIX: Safari flex/grid shrink */
  overflow: hidden; /* FIX: prevent content forcing width */
}
.home-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: var(--accent-soft);
  border-top-color: var(--accent);
}
.home-card-icon {
  margin-bottom: 2px;
}
.home-card h3 {
  font-weight: 700;
  margin-bottom: 1px;
  font-family: var(--font);
}
.home-card p {
  color: var(--text-secondary);
}

.pr-counter-card {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pr-counter-card .pr-icon {
  font-size: 1.25rem;
}
.pr-counter-card .pr-text {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
}
.pr-counter-card .pr-text strong {
  font-size: 1.0625rem;
  color: var(--accent-text);
}

.today-mini-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}
.today-mini-card .plan-left h4 {
  font-weight: 700;
  margin: 0;
  font-size: 0.8125rem;
  font-family: var(--font);
}
.today-mini-card .plan-left .plan-meta {
  font-size: 0.6875rem;
  color: var(--text-secondary);
}
.today-mini-card .rest-badge {
  font-size: 0.625rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--surface-variant);
  padding: 2px 10px;
  border-radius: 20px;
}
.today-mini-card .complete-badge {
  font-size: 0.625rem;
  font-weight: 600;
  color: white;
  background: var(--green);
  padding: 2px 10px;
  border-radius: 20px;
}

.streak-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-sm);
}
.streak-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 6px;
}
.streak-card-header h3 {
  font-weight: 700;
  color: var(--text);
  margin: 0;
  font-family: var(--font);
}
.streak-count {
  background: var(--surface-variant);
  border-radius: 30px;
  font-weight: 600;
  color: var(--text);
  border: 1px solid var(--border);
}
.streak-count .fire {
  margin-right: 4px;
}

.calendar-strip {
  display: flex;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 8px;
  box-shadow: var(--shadow-sm);
}
.cal-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  border-radius: 10px;
  flex: 1;
  transition: background 0.2s;
  min-width: 0; /* FIX: Safari shrink issue */
}
.cal-day.today {
  background: var(--accent-soft);
  border-radius: 10px;
}
.cal-day.today .cal-letter {
  color: var(--accent-text);
}
.cal-day .cal-letter {
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  line-height: 1.4;
}
.cal-day .cal-status {
  line-height: 1.6;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cal-day .cal-session {
  font-weight: 700;
  text-align: center;
  line-height: 1.3;
  color: var(--text-secondary);
  max-width: 40px;
  word-break: break-all;
}
.cal-day.has-session .cal-session {
  color: var(--accent-text);
}
.cal-day.rest .cal-session {
  color: var(--text-muted);
  font-weight: 500;
}

.daily-quote {
  margin-top: 12px;
  padding: 12px 14px;
  background: var(--surface-variant);
  border-radius: 14px;
  text-align: center;
  font-style: italic;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  font-family: var(--font);
}

.top-row-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 4px;
}

.home-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.home-pr-badge {
  background: var(--accent-soft);
  border-radius: 40px;
  padding: 4px 12px;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  font-family: var(--font);
  color: var(--text);
}

.home-card {
  font: inherit;
  color: inherit;
  width: 100%;
  display: block;
}
.home-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.streak-card-header {
  width: 100%;
  background: none;
  border: none;
  font: inherit;
  color: inherit;
  cursor: pointer;
  text-align: left;
}
.streak-card-header:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 8px;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendar-weekday-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  margin-bottom: 4px;
}
.calendar-weekday-header span {
  text-align: center;
  font-size: 0.5625rem;
  font-weight: 600;
  color: var(--text-muted);
}
.cal-day.future {
  opacity: 0.45;
}

.streak-legend {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 10px;
}
.streak-legend .legend-item {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}


/* ================================================================
   HOME PAGE – RESPONSIVE SPACING
   ================================================================ */

.home-container {
  padding: 4px 12px 12px 12px;
}

.home-top-row {
  flex-wrap: wrap;
  gap: 8px 6px;
}
.home-top-row .greeting {
  font-size: clamp(1rem, 4vw, 1.375rem);
}
.home-top-row .home-pr-badge {
  font-size: clamp(0.7rem, 2vw, 0.85rem);
  padding: 4px 10px;
}

.home-cards {
  gap: 8px;
}
.home-card {
  padding: 12px 8px;
  border-radius: 14px;
}
.home-card .home-card-icon {
  font-size: 1.4rem;
}
.home-card h3 {
  font-size: 0.8rem;
}
.home-card p {
  font-size: 0.6rem;
}

.streak-card {
  padding: 16px 12px 12px 12px;
}
.streak-card-header {
  gap: 6px;
}
.streak-card-header h3 {
  font-size: 0.95rem;
}
.streak-count {
  font-size: 0.75rem;
  padding: 2px 10px;
}

.calendar-grid {
  gap: 2px;
}
.cal-day {
  padding: 2px 0;
  min-width: 24px;
}
.cal-day .cal-letter {
  font-size: 0.6rem;
}
.cal-day .cal-status {
  font-size: 0.8rem;
  min-height: 20px;
}
.cal-day .cal-session {
  font-size: 0.4rem;
  min-height: 10px;
}
.streak-legend {
  font-size: 0.6rem;
  gap: 6px;
  margin-top: 8px;
}

.daily-quote {
  font-size: 0.7rem;
  padding: 10px 12px;
  margin-top: 8px;
}

@media (min-width: 600px) {
  .home-container {
    padding: 8px 20px 20px 20px;
  }
  .home-cards {
    gap: 12px;
  }
  .home-card {
    padding: 16px 12px;
  }
  .home-card .home-card-icon {
    font-size: 1.6rem;
  }
  .home-card h3 {
    font-size: 0.9rem;
  }
  .streak-card {
    padding: 20px 16px 16px 16px;
  }
  .calendar-grid {
    gap: 4px;
  }
  .cal-day {
    min-width: 32px;
    padding: 4px 0;
  }
  .cal-day .cal-letter {
    font-size: 0.7rem;
  }
  .cal-day .cal-status {
    font-size: 1rem;
    min-height: 26px;
  }
  .cal-day .cal-session {
    font-size: 0.5rem;
  }
}

@media (min-width: 1024px) {
  .home-container {
    padding: 8px 0 20px 0;
  }
  .home-cards {
    gap: 16px;
  }
  .home-card {
    padding: 18px 14px;
  }
  .home-card .home-card-icon {
    font-size: 1.8rem;
  }
  .home-card h3 {
    font-size: 1rem;
  }
}


/* ================================================================
   HOME PAGE – full-width, no horizontal scroll
   ================================================================ */

#app {
  max-width: 820px;
  width: 100%;
  margin: 0 auto;
  /* FIX: was a flat padding:0 — this is the rule that actually wins in
     cascade order over the earlier #app selector's own padding (if it
     had any), so this is the one that needed the safe-area insets.
     env() with a fallback resolves to that fallback on any browser
     without safe-area support, so this is harmless to apply
     unconditionally rather than gating it behind a standalone-mode
     check. */
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
  overflow-x: hidden;
}

.home-container {
  padding: 8px 0 16px 0;
  width: 100%;
  overflow: hidden;
}
.home-card {
  border-left: none !important;
}
.home-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
}
.home-card {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
  padding: 14px 10px;
  min-width: 0; /* FIX: Safari flex/grid shrink */
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  width: 100%;
}
.cal-day {
  min-width: 0; /* FIX: Safari shrink */
  padding: 4px 0;
}
@media (max-width: 600px) {
  #app { padding: 0 12px; }
  .home-cards { gap: 6px; }
  .home-card { padding: 10px 6px; }
  .app-logo { height: 30px; }
  .app-header { height: 54px; }
  .header-icon-btn { width: 30px; height: 30px; font-size: 0.9rem; }
  .logout-button { font-size: 0.5rem; padding: 4px 8px; }
  .logout-button svg { width: 10px; height: 10px; }
}
@media (max-width: 400px) {
  #app { padding: 0 8px; }
  .home-cards { gap: 4px; }
  .home-card { padding: 8px 4px; }
  .app-logo { height: 26px; }
  .app-header { height: 48px; }
  .header-icon-btn { width: 26px; height: 26px; font-size: 0.8rem; }
  .logout-button { font-size: 0.45rem; padding: 3px 6px; }
  .logout-button svg { width: 9px; height: 9px; }
}

