/*
 * Week grid and chore colors.
 *
 * Each chore color is a tint / strip / ink triple that keeps AA contrast on its
 * tint. `.chore-<color>` sets the variables; `.occurrence` and `.chore-dot` use them.
 */

.chore-blue   { --chore-tint: #E8F0FE; --chore-strip: #1A73E8; --chore-ink: #174EA6; }
.chore-green  { --chore-tint: #E6F4EA; --chore-strip: #1E8E3E; --chore-ink: #137333; }
.chore-amber  { --chore-tint: #FEF7E0; --chore-strip: #F9AB00; --chore-ink: #8A5300; }
.chore-purple { --chore-tint: #F3E8FD; --chore-strip: #8430CE; --chore-ink: #681DA8; }
.chore-teal   { --chore-tint: #E4F7FB; --chore-strip: #129EAF; --chore-ink: #006064; }
.chore-coral  { --chore-tint: #FCE8E6; --chore-strip: #D93025; --chore-ink: #A50E0E; }
.chore-pink   { --chore-tint: #FDE7F3; --chore-strip: #D01884; --chore-ink: #9C166B; }
.chore-grey   { --chore-tint: #F1F3F4; --chore-strip: #80868B; --chore-ink: #3C4043; }
.chore-indigo { --chore-tint: #E8EAF6; --chore-strip: #3F51B5; --chore-ink: #283593; }

.chore-dot {
  background: var(--chore-strip);
}

.occurrence {
  background: var(--chore-tint);
  border-left: 3px solid var(--chore-strip);
  color: var(--chore-ink);
}

.occurrence.is-done,
.occurrence.is-skipped {
  --chore-tint: #F1F3F4;
  --chore-strip: #BDC1C6;
  --chore-ink: #5F6368;
}

.occurrence-toggle {
  color: inherit;
}

.occurrence-toggle:hover {
  background: rgb(0 0 0 / 0.06);
}

/*
 * The week grid: a gutter for hour labels plus one column per visible day.
 * --visible-days is set by the day-window controller (7 on desktop; 7, 3 or 1
 * on phones); columns outside the window get .is-outside-window.
 */
.week {
  --gutter: 56px;
  --visible-days: 7;
}

.week-row {
  display: grid;
  grid-template-columns: var(--gutter) repeat(var(--visible-days), minmax(0, 1fr));
}

.is-outside-window {
  display: none;
}

@media (max-width: 639px) {
  .week {
    --gutter: 32px;
  }

  .occurrence {
    font-size: 11px;
  }
}

/* Hour lines, one per --hour-height (set inline on #week from CalendarHelper::HOUR_HEIGHT). */
.hour-grid {
  background-image: repeating-linear-gradient(
    to bottom,
    var(--color-line-soft) 0,
    var(--color-line-soft) 1px,
    transparent 1px,
    transparent var(--hour-height)
  );
}

.now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  background: #D93025;
  z-index: 20;
  pointer-events: none;
}

.now-line::before {
  content: "";
  position: absolute;
  left: -6px;
  top: -5px;
  width: 12px;
  height: 12px;
  border-radius: 6px;
  background: #D93025;
}

/* Drag and drop. */
.is-draggable {
  cursor: grab;
  user-select: none;
  -webkit-touch-callout: none;   /* no link preview on a long press (iOS) */
}

/* The link inside a card opens the editor; it shows no iOS link preview on a long
   press and, on a draggable card, keeps the grab cursor like the sidebar tiles do. */
.occurrence a {
  -webkit-touch-callout: none;
}

.is-draggable a {
  cursor: inherit;
}

/* The grid scrolls vertically with a finger; horizontal swipes reach the day-window controller. */
#calendar {
  touch-action: pan-y;
}

.is-dragging {
  opacity: 0.35;
}

body.is-dragging-chore,
body.is-dragging-chore .is-draggable {
  cursor: grabbing;
  user-select: none;
}

.drag-ghost {
  position: fixed;
  z-index: 100;
  pointer-events: none;
  opacity: 0.95;
  box-shadow: 0 10px 28px rgb(60 64 67 / 0.32);
  transform-origin: top left;
}

.drag-ghost[data-drag-kind="chore"] {
  rotate: -2deg;
}

.drop-cell.is-drop-target {
  background-color: rgb(26 115 232 / 0.06);
}

.drop-indicator {
  position: absolute;
  left: 3px;
  right: 5px;
  z-index: 15;
  pointer-events: none;
  border: 2px dashed var(--color-accent);
  border-radius: 6px;
  background: rgb(26 115 232 / 0.1);
}

.drop-indicator-label {
  position: absolute;
  top: -24px;
  left: 0;
  white-space: nowrap;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--color-accent-strong);
  color: #fff;
  font-size: 11px;
  line-height: 16px;
  font-weight: 500;
}

.drop-indicator.is-all-day {
  position: relative;
  left: 0;
  right: 0;
  height: 28px;
  margin-top: 4px;
}

.drop-indicator.is-all-day .drop-indicator-label {
  top: 4px;
  left: 6px;
}

/* Toasts: flash messages and move confirmations. */
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  background: var(--color-ink);
  color: #fff;
  font-size: 0.875rem;
  line-height: 1.25rem;
  box-shadow: 0 8px 24px rgb(32 33 36 / 0.3);
}

.toast form {
  display: inline;
}

/* Touch screens: the done toggle gets a bigger hit area inside the card. */
@media (pointer: coarse) {
  .occurrence-toggle {
    width: 28px;
    height: 28px;
    margin: -6px 0 -6px -6px;
  }
}

/*
 * Phones: the sidebar and the calendar are tabs (data-tab on the screen), the
 * week title/view mode row and the day strip belong to the calendar tab, and
 * the day strip only shows in the 3-day and day views (data-visible-days).
 */
.tab-bar .tab {
  color: var(--color-ink-muted);
  cursor: pointer;
}

.tab-bar .tab + .tab {
  border-left: 1px solid var(--color-line);
}

.tab-bar .tab[aria-selected="true"] {
  background: var(--color-accent-soft);
  color: var(--color-accent-strong);
}

.day-strip {
  display: none;
  height: 3.25rem;
  align-items: center;
  padding: 0 0.25rem;
}

.day-chip {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 4px 0;
  cursor: pointer;
}

.day-chip-name {
  font-size: 10px;
  line-height: 12px;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--color-ink-muted);
}

.day-chip-number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 15px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-ink);
}

.day-chip.is-today .day-chip-name,
.day-chip.is-today .day-chip-number {
  color: var(--color-accent-strong);
  font-weight: 600;
}

.day-chip.is-selected .day-chip-number {
  background: var(--color-accent);
  color: #fff;
}

@media (max-width: 767px) {
  [data-visible-days="1"] .day-strip,
  [data-visible-days="3"] .day-strip {
    display: flex;
  }

  [data-tab="calendar"] #sidebar {
    display: none;
  }

  [data-tab="chores"] #calendar,
  [data-tab="chores"] .calendar-only {
    display: none;
  }
}
