/*
  The calendar on the page skeleton (docs/design/skeleton-b-calendar-today.md), after the approved structure mock:
  the view tabs, the range with its steps, the week strip with category dots, the day in fixed sections of plain
  rows, the week as one list (seven columns from 900px), the month grid, the filter sheet and the sentence entry's
  kind chip. Builds on the tokens of hauswerk.css and the skeleton parts of skeleton.css.
*/

/* Seven week columns need the room; the day and the month keep the reading width. */
.hw-content:has(> .hw-cal-is-week) {
  max-width: 1280px;
}

.hw-cal {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.hw-cal-household { --hw-cal-c: var(--hw-house); --hw-cal-cs: var(--hw-house-soft); }
.hw-cal-meals { --hw-cal-c: var(--hw-meal); --hw-cal-cs: var(--hw-meal-soft); }
.hw-cal-activities { --hw-cal-c: var(--hw-act); --hw-cal-cs: var(--hw-act-soft); }

/* --- range ------------------------------------------------------------------------------ */

.hw-cal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: -4px;
}

.hw-cal-range {
  flex: 1;
  min-width: 0;
  font-family: var(--hw-font-display);
  font-weight: 700;
  font-size: 16px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

/* --- week strip ------------------------------------------------------------------------ */

.hw-cal-strip {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  touch-action: pan-y;
}

.hw-cal-strip-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 56px;
  padding: 6px 0 7px;
  border: 0;
  border-radius: 14px;
  background: none;
  color: var(--bsft-color-text);
  font: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.hw-cal-strip-day small {
  font-size: 11.5px;
  color: var(--bsft-color-muted);
}

.hw-cal-strip-day b {
  font-family: var(--hw-font-display);
  font-size: 17px;
}

.hw-cal-is-day .hw-cal-strip-day[aria-pressed="true"] {
  background: var(--bsft-color-text);
  color: var(--bsft-color-surface);
}

.hw-cal-is-day .hw-cal-strip-day[aria-pressed="true"] small {
  color: var(--bsft-color-surface);
}

.hw-cal-strip-day.is-today b {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.hw-cal-dots {
  display: flex;
  gap: 3px;
  height: 6px;
}

.hw-cal-dot {
  display: inline-block;
  flex: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--hw-cal-c, var(--bsft-color-primary));
}

/* --- filter sheet and tray -------------------------------------------------------------- */

.hw-cal-filter .hw-cal-dot {
  width: 9px;
  height: 9px;
  margin-right: 6px;
}

.hw-cal-filter[aria-pressed="true"] {
  background: var(--hw-cal-cs, var(--hw-accent-soft));
  border-color: var(--hw-cal-c, var(--bsft-color-primary));
  color: var(--bsft-color-text);
}

.hw-cal-filter[aria-pressed="false"] {
  color: var(--bsft-color-muted);
}

.hw-cal-filter[aria-pressed="false"] .hw-cal-dot {
  background: var(--bsft-color-border);
}

.hw-cal-filter-sheet .hw-sheet-label {
  margin: 4px 0 -6px;
}

.hw-meal-tray-chip[draggable="true"] {
  cursor: grab;
}

/* --- the day: sections of plain rows --------------------------------------------------- */

.hw-cal-dayhead {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin: 2px 2px 8px;
}

.hw-cal-dayhead h2 {
  margin: 0;
  font-family: var(--hw-font-display);
  font-size: 19px;
  font-weight: 700;
}

.hw-cal-dayhead span {
  font-size: 13px;
  color: var(--bsft-color-muted);
}

.hw-cal-section {
  margin-bottom: 14px;
}

.hw-cal-section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 2px 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bsft-color-muted);
}

.hw-cal-section-head .hw-cal-dot {
  width: 8px;
  height: 8px;
}

.hw-cal-section-count {
  margin-left: auto;
  font-weight: 400;
  letter-spacing: 0;
  text-transform: none;
}

.hw-cal-list {
  overflow: hidden;
  border: 1px solid var(--bsft-color-border);
  border-radius: 14px;
  background: var(--bsft-color-surface);
}

.hw-cal-list:empty {
  display: none;
}

.hw-cal-row + .hw-cal-row,
.hw-cal-row + .hw-cal-free {
  border-top: 1px solid var(--bsft-color-border);
}

.hw-cal-row-main {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 52px;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  color: var(--bsft-color-text);
  font: inherit;
  text-align: left;
  text-decoration: none;
}

button.hw-cal-row-main,
a.hw-cal-row-main {
  cursor: pointer;
}

button.hw-cal-row-main:hover:not(:disabled),
a.hw-cal-row-main:hover {
  background: var(--hw-surface-2);
}

button.hw-cal-row-main:disabled {
  cursor: default;
}

.hw-cal-row-main:focus-visible {
  outline-offset: -2px;
}

.hw-cal-row-main[draggable="true"] {
  cursor: grab;
}

.hw-cal-when {
  width: 42px;
  flex: none;
  font-family: var(--hw-font-mono);
  font-size: 12.5px;
  color: var(--bsft-color-muted);
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hw-cal-text {
  flex: 1;
  min-width: 0;
}

.hw-cal-text b,
.hw-cal-text small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hw-cal-text b {
  font-weight: 700;
}

.hw-cal-text small {
  font-size: 12.5px;
  color: var(--bsft-color-muted);
}

.hw-cal-nothing {
  margin: 4px 2px;
  color: var(--bsft-color-muted);
}

/* The meals of a day still free: one quiet dashed row with a dashed plus. */
.hw-cal-free {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 6px 14px;
  border: 0;
  border-top: 1px dashed var(--bsft-color-border);
  background: transparent;
  color: var(--bsft-color-muted);
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.hw-cal-list > .hw-cal-free:first-child {
  border-top: 0;
}

.hw-cal-free:hover:not(:disabled) {
  color: var(--bsft-color-primary);
}

.hw-cal-free-plus {
  display: grid;
  place-items: center;
  flex: none;
  width: 22px;
  height: 22px;
  border: 1.5px dashed currentColor;
  border-radius: 50%;
}

.hw-cal-free-plus .hw-icon {
  width: 12px;
  height: 12px;
}

/* The round check of a routine, as in the mock: an empty ring, filled in the routine colour once done. */
.hw-check-round {
  display: grid;
  place-items: center;
  flex: none;
  width: 24px;
  height: 24px;
  border: 2px solid var(--bsft-color-border);
  border-radius: 50%;
  color: transparent;
}

.hw-check-round .hw-icon {
  width: 14px;
  height: 14px;
}

[aria-pressed="true"] > .hw-check-round {
  border-color: var(--hw-check-c, var(--hw-routine));
  background: var(--hw-check-c, var(--hw-routine));
  color: var(--bsft-color-surface);
}

.hw-cal-row.is-done .hw-cal-text b {
  color: var(--bsft-color-muted);
  text-decoration: line-through;
}

/* --- the week as one list ------------------------------------------------------------- */

.hw-cal-week {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.hw-cal-weekday.is-empty {
  display: none;
}

.hw-cal-weekday-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  min-height: 36px;
  margin: 0 2px 4px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--bsft-color-text);
  font: inherit;
  cursor: pointer;
}

.hw-cal-weekday-head span {
  font-weight: 700;
}

.hw-cal-weekday-head b {
  font-weight: 400;
  font-size: 13px;
  color: var(--bsft-color-muted);
}

.hw-cal-weekday.is-today .hw-cal-weekday-head span {
  color: var(--bsft-color-primary);
}

.hw-cal-weekday.is-drop .hw-cal-list {
  border-color: var(--bsft-color-primary);
  box-shadow: inset 0 0 0 1px var(--bsft-color-primary);
}

/* --- the sentence entry's kind -------------------------------------------------------- */

.hw-kind-meal { --hw-kind-c: var(--hw-meal); --hw-kind-cs: var(--hw-meal-soft); }
.hw-kind-chore { --hw-kind-c: var(--hw-house); --hw-kind-cs: var(--hw-house-soft); }
.hw-kind-activity { --hw-kind-c: var(--hw-act); --hw-kind-cs: var(--hw-act-soft); }
.hw-kind-routine { --hw-kind-c: var(--hw-routine); --hw-kind-cs: var(--hw-routine-soft); }
.hw-kind-shopping { --hw-kind-c: var(--bsft-color-primary); --hw-kind-cs: var(--hw-accent-soft); }
.hw-kind-reminder { --hw-kind-c: var(--hw-act); --hw-kind-cs: var(--hw-act-soft); }
.hw-kind-birthday { --hw-kind-c: var(--hw-act); --hw-kind-cs: var(--hw-act-soft); }
.hw-kind-helpnote { --hw-kind-c: var(--hw-house); --hw-kind-cs: var(--hw-house-soft); }

.hw-sentence {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.hw-sentence-preview {
  margin-top: 0;
}

.hw-sentence-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: var(--hw-kind-cs);
  color: var(--hw-kind-c);
  font: inherit;
  font-size: 13px;
  font-weight: 700;
}

button.hw-sentence-chip {
  cursor: pointer;
}

button.hw-sentence-chip::after {
  content: "";
  width: 6px;
  height: 6px;
  margin: -3px 0 0 7px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
}

button.hw-sentence-chip[aria-expanded="true"] {
  border-color: var(--hw-kind-c);
}

.hw-sentence-preview button.hw-preview-part {
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.hw-sentence-preview button.hw-preview-part[aria-expanded="true"] {
  border-style: solid;
}

.hw-sentence-kind[aria-pressed="true"] {
  background: var(--hw-kind-cs);
  border-color: var(--hw-kind-c);
  color: var(--hw-kind-c);
}

.hw-sentence-choice {
  margin-top: 2px;
}

/* --- month grid ----------------------------------------------------------------------- */

.hw-cal-month {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.hw-cal-month-weekday {
  text-align: center;
  font-size: 11.5px;
  color: var(--bsft-color-muted);
}

.hw-cal-month-day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  min-height: 52px;
  padding: 6px 2px;
  border: 1px solid var(--bsft-color-border);
  border-radius: 12px;
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  font: inherit;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  min-width: 0;
}

.hw-cal-month-day b {
  font-family: var(--hw-font-display);
  font-size: 15px;
}

.hw-cal-month-day.is-outside {
  background: transparent;
  color: var(--bsft-color-muted);
}

.hw-cal-month-day[aria-pressed="true"] {
  background: var(--bsft-color-text);
  border-color: var(--bsft-color-text);
  color: var(--bsft-color-surface);
}

.hw-cal-month-day.is-today b {
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.hw-cal-month-titles {
  display: none;
}

.hw-cal-month-agenda {
  margin-top: 4px;
}

/* --- desktop ---------------------------------------------------------------------------- */

@media (min-width: 900px) {
  .hw-cal-toolbar {
    justify-content: flex-start;
  }

  .hw-cal-range {
    flex: none;
    min-width: 200px;
  }

  .hw-cal-is-day .hw-cal-daylist,
  .hw-cal-month-agenda {
    max-width: 640px;
  }

  .hw-cal-is-week .hw-cal-strip {
    display: none;
  }

  .hw-cal-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 8px;
    align-items: start;
  }

  .hw-cal-weekday.is-empty {
    display: block;
  }

  .hw-cal-weekday .hw-cal-list {
    min-height: 180px;
  }

  .hw-cal-weekday .hw-cal-list:empty {
    display: block;
  }

  .hw-cal-weekday-head {
    flex-direction: column;
    gap: 0;
  }

  .hw-cal-week > .hw-cal-nothing {
    grid-column: 1 / -1;
  }

  .hw-cal-week .hw-cal-row-main {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 2px 6px;
    min-height: 44px;
    padding: 7px 8px;
    border-left: 3px solid var(--hw-cal-c);
  }

  .hw-cal-week .hw-cal-when {
    width: auto;
    flex-basis: 100%;
  }

  .hw-cal-week .hw-cal-text b {
    font-size: 14px;
    white-space: normal;
    overflow-wrap: anywhere;
  }

  /* In a narrow day column the title takes the whole width; the reminder goes below it. */
  .hw-cal-week .hw-cal-text {
    flex: 1 1 100%;
  }

  .hw-cal-week .hw-act-bell {
    flex-basis: auto;
  }

  .hw-cal-month-day {
    align-items: stretch;
    min-height: 104px;
    padding: 6px 8px;
  }

  .hw-cal-month-day b {
    text-align: left;
  }

  .hw-cal-month-day[aria-pressed="true"] {
    background: var(--bsft-color-surface);
    border-color: var(--bsft-color-primary);
    color: var(--bsft-color-text);
    box-shadow: inset 0 0 0 1px var(--bsft-color-primary);
  }

  .hw-cal-month-day .hw-cal-dots {
    display: none;
  }

  .hw-cal-month-titles {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
  }

  .hw-cal-month-title {
    font-size: 12px;
    text-align: left;
    padding: 1px 6px;
    border-radius: 6px;
    background: var(--hw-cal-cs);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* --- activities ---------------------------------------------------------------------- */

.hw-act-proposal {
  font-weight: 700;
  color: var(--hw-act);
}

.hw-act-part,
.hw-act-ask,
.hw-act-form {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.hw-act-part input,
.hw-act-form input {
  min-width: 0;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--bsft-color-border);
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  font: inherit;
  font-size: 16px;
}

.hw-act-part input[type="text"] {
  flex: 1 1 12rem;
}

.hw-act-form label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  color: var(--bsft-color-muted);
}

.hw-act-ask {
  font-size: 14px;
}

.hw-act-actions .hw-sheet-confirm {
  margin-top: 8px;
}

.hw-act-bell {
  align-self: center;
  flex: none;
}

.hw-act-bell .hw-icon {
  width: 12px;
  height: 12px;
}

.hw-act-repeat {
  display: inline-block;
  margin-left: 4px;
  color: var(--bsft-color-muted);
  vertical-align: -2px;
}

.hw-act-repeat .hw-icon {
  width: 14px;
  height: 14px;
}

.hw-cal-row.is-cancelled .hw-cal-text b {
  text-decoration: line-through;
  color: var(--bsft-color-muted);
}

.hw-act-away {
  margin: 4px 0;
  padding: 9px 12px;
  border-radius: 12px;
  background: var(--hw-act-soft);
  color: var(--bsft-color-text);
  font-size: 13.5px;
}

.hw-act-sheet .hw-sheet-dates {
  align-items: flex-end;
}

.hw-act-sheet-details {
  margin-bottom: 12px;
}

.hw-act-drivers select {
  min-height: 2.25rem;
}

/* --- the smart entry sheet ------------------------------------------------------------ */

.hw-entry-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hw-entry-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--bsft-color-border);
  border-left: 4px solid var(--hw-kind-c);
  border-radius: 12px;
  background: var(--bsft-color-surface);
}

/* While the entry is understood: what was said as a quiet quote, and calm placeholder rows. */
.hw-entry-quote {
  margin: 0 0 12px;
  padding: 2px 0 2px 12px;
  border-left: 3px solid var(--bsft-color-border);
  color: var(--bsft-color-muted);
  font-style: italic;
  overflow-wrap: anywhere;
}

.hw-entry-row-skeleton {
  border-left-color: var(--bsft-color-border);
}

.hw-entry-row-skeleton span {
  display: block;
  height: 14px;
  border-radius: 7px;
  background: linear-gradient(90deg, var(--hw-surface-2) 0%, var(--bsft-color-border) 50%, var(--hw-surface-2) 100%);
  background-size: 200% 100%;
  animation: hw-entry-shimmer 1.6s ease-in-out infinite;
}

.hw-entry-row-skeleton span:first-child {
  width: 30%;
}

.hw-entry-row-skeleton span:last-child {
  width: 70%;
  height: 36px;
  border-radius: 8px;
}

@keyframes hw-entry-shimmer {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.hw-smart-field input[aria-invalid="true"] {
  border-color: var(--bsft-color-danger);
}

.hw-entry-row-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.hw-entry-row-people {
  min-width: 0;
  overflow: hidden;
  color: var(--bsft-color-muted);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The details line of a row: quiet like the people it names, the chevron says it opens the row's details. */
.hw-link-button.hw-entry-row-details {
  min-width: 0;
  min-height: 40px;
  color: var(--bsft-color-muted);
  font-weight: 400;
}

.hw-entry-row-details .hw-icon {
  flex: none;
  width: 16px;
  height: 16px;
}

.hw-entry-details {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hw-entry-details-title {
  margin: 0;
  font-family: var(--hw-font-display);
  font-size: 18px;
  font-weight: 700;
}

.hw-entry-details-amount {
  max-width: 10rem;
}

.hw-entry-row-remove {
  margin-left: auto;
}

.hw-entry-row-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.hw-smart-field {
  display: flex;
  flex: 1 1 120px;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  color: var(--bsft-color-muted);
  font-size: 13px;
}

.hw-smart-field-title {
  flex-basis: 100%;
}

.hw-smart-field input {
  min-width: 0;
  min-height: 40px;
  padding: 6px 10px;
  border: 1px solid var(--bsft-color-border);
  border-radius: 10px;
  background: var(--bsft-color-surface);
  color: var(--bsft-color-text);
  font: inherit;
  font-size: 16px;
}

.hw-entry-hints {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  font-size: 13px;
}

.hw-entry-hint {
  display: flex;
  flex: 1 1 100%;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.hw-entry-hint-note {
  color: var(--bsft-color-muted);
}

.hw-entry-hint-photo {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
}
