/* Per-widget content. Cards themselves are .widget in base.css. */

/* Calendar -------------------------------------------------------------- */

.cal-next {
  flex: none;
  padding-left: var(--space-3);
  border-left: 4px solid var(--event, var(--system-blue));
}

.cal-kicker {
  color: var(--system-red);
  font-size: var(--text-caption);
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cal-hero-time {
  margin-top: 2px;
  font-size: var(--text-hero);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-clock);
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
}

.cal-next.is-all-day .cal-hero-time {
  font-size: var(--text-title);
  letter-spacing: var(--tracking-title);
}

.cal-next__title {
  margin-top: var(--space-2);
  font-size: var(--text-title);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-title);
  line-height: var(--leading-tight);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cal-next__meta {
  margin-top: 4px;
  color: var(--secondary-label);
  font-size: var(--text-subhead);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-list {
  margin-top: var(--space-3);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 2px;
}

.cal-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-height: 28px;
}

.dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--event, var(--system-blue));
}

.cal-row__title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-callout);
  font-weight: var(--weight-medium);
}

.cal-row__when {
  flex: none;
  color: var(--secondary-label);
  font-size: var(--text-subhead);
  font-variant-numeric: tabular-nums;
  font-weight: var(--weight-medium);
}

/* Weather --------------------------------------------------------------- */

.wx-now {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.wx-temp {
  font-size: var(--text-hero);
  font-weight: var(--weight-medium);
  letter-spacing: var(--tracking-clock);
  line-height: 0.9;
  font-variant-numeric: tabular-nums;
}

.wx-cond {
  margin-top: 0;
  font-size: var(--text-subhead);
  font-weight: var(--weight-medium);
  line-height: 1.05;
  color: var(--secondary-label);
}

.wx-stats {
  margin-top: var(--space-1);
  display: flex;
  flex-wrap: wrap;
  gap: 2px var(--space-3);
  color: var(--secondary-label);
  font-size: var(--text-caption);
  font-weight: var(--weight-medium);
  line-height: 1.05;
}

.wx {
  width: 18px;
  height: 18px;
  display: block;
}

.wx--lg {
  width: 32px;
  height: 32px;
  flex: none;
}

.wx--sun { color: var(--system-orange); }
.wx--cloud { color: var(--system-gray); }
.wx--part { color: var(--system-orange); }
.wx--rain { color: var(--system-blue); }
.wx--storm { color: var(--system-purple); }
.wx--fog { color: var(--system-gray); }

.hourly,
.daily {
  display: grid;
  gap: var(--space-1);
}

.widget--weather .widget__body {
  justify-content: space-between;
}

.hourly {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.daily {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.day .wx {
  width: 16px;
  height: 16px;
}

.hour,
.day {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  min-width: 0;
  text-align: center;
  line-height: 1.05;
}

.hour__time,
.day__name {
  color: var(--secondary-label);
  font-size: var(--text-footnote);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}

.hour__temp,
.day__temps {
  font-size: var(--text-caption);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}

/* Max and min stay on one line. Two-digit pairs wrap when the caption outgrows the column. */
.day__temps {
  white-space: nowrap;
}

@media (max-width: 1100px) and (max-height: 820px) and (orientation: landscape) {
  .day__temps {
    font-size: 14px;
  }
}

@media (min-width: 1300px) and (max-height: 1100px) {
  .day__temps {
    font-size: min(var(--text-caption), 18px);
  }
}

.day__temps span {
  color: var(--secondary-label);
  font-weight: var(--weight-medium);
}

/* Tesla ----------------------------------------------------------------- */

.tesla {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.ring-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  width: 100%;
  display: grid;
  place-items: center;
}

.ring-wrap svg {
  height: 100%;
  width: auto;
  max-height: 100%;
}

.ring__track {
  fill: none;
  stroke: var(--tertiary-system-fill);
  stroke-width: 8;
}

.ring__value {
  fill: none;
  stroke: var(--ring, var(--system-green));
  stroke-width: 8;
  stroke-linecap: round;
}

.ring__limit {
  fill: var(--label);
}

.ring-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(28px, 1.6vw + 1.5vh, 48px);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-title);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.ring-label span {
  margin-left: 1px;
  font-size: 0.45em;
  font-weight: var(--weight-semibold);
  color: var(--secondary-label);
}

.tesla-status,
.tesla-range {
  flex: none;
}

.tesla-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: var(--space-1);
  font-size: var(--text-subhead);
  font-weight: var(--weight-semibold);
  color: var(--secondary-label);
}

.tesla.is-good { --ring: var(--system-green); }
.tesla.is-good .tesla-status { color: var(--system-green); }
.tesla.is-bad { --ring: var(--system-red); }
.tesla.is-bad .tesla-status { color: var(--system-red); }
.tesla.is-neutral { --ring: var(--system-blue); }

.bolt {
  width: 1em;
  height: 1em;
  display: block;
  fill: currentColor;
}

.tesla-range {
  margin-top: 2px;
  font-size: var(--text-title);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-title);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.tesla-range small {
  margin-left: 2px;
  font-size: 0.55em;
  font-weight: var(--weight-medium);
  color: var(--secondary-label);
}

/* Shopping -------------------------------------------------------------- */

.widget--shopping {
  padding: 12px 16px;
}

.widget--shopping.is-stale .widget__head,
.widget--shopping.is-stale .shop-toolbar,
.widget--shopping.is-stale .shop-list {
  opacity: 0.72;
}

.shop-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 4px;
}

.shop-count {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  flex: none;
}

.shop-count strong {
  font-size: clamp(24px, 1.4vw + 1.2vh, 40px);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-title);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.shop-count span {
  color: var(--secondary-label);
  font-size: var(--text-subhead);
  font-weight: var(--weight-medium);
}

.shop-add {
  display: flex;
  flex: 1;
  min-width: 0;
  gap: var(--space-2);
}

.shop-add input {
  flex: 1;
  min-width: 0;
  height: 36px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-s);
  background: var(--tertiary-system-fill);
  color: var(--label);
  padding: 0 12px;
  font: inherit;
  font-size: var(--text-callout);
}

.shop-add button,
.sheet__actions button {
  flex: none;
  height: 36px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--system-orange);
  color: var(--on-tint);
  padding: 0 14px;
  font: inherit;
  font-size: var(--text-subhead);
  font-weight: var(--weight-semibold);
}

.shop-banner {
  margin: 0 0 4px;
  color: var(--secondary-label);
  font-size: var(--text-subhead);
  font-weight: var(--weight-semibold);
  line-height: 1.15;
}

.shop-banner[data-state="offline"],
.shop-banner[data-state="stale"] {
  color: var(--system-orange-text);
}

.shop-note {
  margin: 0 0 4px;
  color: var(--secondary-label);
  font-size: var(--text-subhead);
  font-weight: var(--weight-regular);
  line-height: 1.2;
}

.shop-note.is-pulse {
  border-radius: var(--radius-s);
  outline: 2px solid var(--system-orange-text);
  outline-offset: 2px;
  background: color-mix(in srgb, var(--system-orange) 22%, transparent);
}

.shop-list {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  align-content: safe center;
  gap: var(--space-2) var(--space-4);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.shop-list > li.shop-row--pending {
  grid-column: 1 / -1;
}

.widget--shopping.is-scrollable .shop-list {
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 36px), transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0, #000 calc(100% - 36px), transparent 100%);
}

.shop-more {
  position: absolute;
  right: 16px;
  bottom: 8px;
  z-index: 1;
  margin: 0;
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--widget-fill-solid);
  color: var(--label);
  font-size: var(--text-footnote);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  pointer-events: none;
}

.shop-more[hidden] {
  display: none;
}

.shop-list > li {
  min-width: 0;
}

.shop-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.shop-check {
  width: 20px;
  height: 20px;
  flex: none;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--tertiary-label);
  display: grid;
  place-items: center;
}

.shop-item[data-priority="1"] .shop-check {
  border-color: var(--system-red);
}

.shop-item[data-priority="5"] .shop-check {
  border-color: var(--system-orange);
}

.shop-item.is-done .shop-check {
  background: var(--system-green);
  border-color: transparent;
}

.shop-item.is-done .shop-check::after,
.task[aria-pressed="true"] .task__box::after {
  content: "";
  width: 5px;
  height: 9px;
  border: solid var(--on-tint);
  border-width: 0 2px 2px 0;
  transform: translateY(-1px) rotate(45deg);
}

.shop-item__copy {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.shop-item__title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-callout);
  font-weight: var(--weight-medium);
}

.shop-item__note {
  color: var(--secondary-label);
  font-size: var(--text-footnote);
  font-weight: var(--weight-medium);
  line-height: 1.25;
  white-space: normal;
}

.shop-row--pending .shop-item {
  align-items: flex-start;
  padding: 2px 0;
}

.shop-item.is-done .shop-item__title {
  color: var(--secondary-label);
  text-decoration: line-through;
}

.shop-item__due {
  flex: none;
  color: var(--system-orange);
  font-size: var(--text-footnote);
  font-weight: var(--weight-semibold);
}

/* Kids ------------------------------------------------------------------- */

.kids {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.kid__head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-2);
}

.avatar {
  width: 32px;
  height: 32px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--radius-pill);
  background: var(--kid-tint, var(--system-blue));
  color: var(--on-tint);
  font-size: var(--text-subhead);
  font-weight: var(--weight-bold);
}

.kid__name {
  font-size: var(--text-title);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-title);
  line-height: 1.1;
}

.kid__meta {
  margin-left: auto;
  color: var(--secondary-label);
  font-size: var(--text-subhead);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}

.kid__meta.is-done {
  color: var(--system-green);
}

.kid {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.kid__tasks {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.task {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  flex: 1 1 auto;
  min-height: 44px;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--radius-m);
  background: var(--secondary-system-fill);
  text-align: left;
  cursor: pointer;
}

.task__box {
  width: 26px;
  height: 26px;
  flex: none;
  border-radius: var(--radius-pill);
  border: 2px solid var(--tertiary-label);
  display: grid;
  place-items: center;
}

.task[aria-pressed="true"] .task__box {
  background: var(--kid-tint, var(--system-green));
  border-color: transparent;
}

.task__label {
  font-size: var(--text-body);
  font-weight: var(--weight-medium);
}

.task[aria-pressed="true"] .task__label {
  color: var(--secondary-label);
  text-decoration: line-through;
}

@media (hover: hover) and (pointer: fine) {
  .task:hover {
    background: var(--system-fill);
  }
}

@media (orientation: portrait), (max-width: 900px) {
  .shop-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* Wide portrait tablet: two children side by side, shopping stays one shelf. */
@media (orientation: portrait) and (min-width: 700px) and (min-height: 1000px) {
  .kids {
    flex-direction: row;
    align-items: stretch;
    gap: var(--space-4);
  }

  .shop-list {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.sheet {
  width: min(440px, calc(100vw - 32px));
  padding: 0;
  border: 0;
  border-radius: var(--radius-widget);
  background: transparent;
  color: var(--label);
}

.sheet::backdrop {
  background: rgba(0, 0, 0, 0.4);
}

.sheet__card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: 0;
  padding: var(--space-5);
  border-radius: var(--radius-widget);
  background: var(--system-background);
}

.sheet__card h2 {
  font-size: var(--text-title);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-title);
}

.sheet__card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  color: var(--secondary-label);
  font-size: var(--text-subhead);
  font-weight: var(--weight-semibold);
}

.sheet__card input {
  height: 44px;
  border: 1px solid var(--separator);
  border-radius: var(--radius-s);
  background: var(--secondary-system-background);
  color: var(--label);
  padding: 0 12px;
  font: inherit;
  font-size: var(--text-callout);
  font-weight: var(--weight-regular);
}

.sheet__note,
.sheet__error,
.sheet__token {
  color: var(--secondary-label);
  font-size: var(--text-subhead);
}

.sheet__token {
  margin: 0;
  color: var(--label);
  letter-spacing: 0.08em;
}

.sheet__error {
  color: var(--system-red);
}

.sheet__actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.sheet__actions button[data-clear],
.sheet__actions button[data-close],
.sheet__actions button[data-cancel-clear],
.sheet__actions button[data-send-local] {
  background: var(--tertiary-system-fill);
  color: var(--label);
}

.sheet__actions button.sheet__danger {
  background: var(--system-red);
  color: var(--on-tint);
}

.sheet__confirm {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sheet__confirm[hidden],
.sheet__local[hidden],
.gate__pad[hidden],
.gate__entry[hidden] {
  display: none;
}

.sheet__local {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.gate__question {
  margin: 0;
  font-size: var(--text-title);
  font-weight: var(--weight-semibold);
}

.gate__entry {
  min-height: 1.3em;
  margin: 0;
  font-size: var(--text-title);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
}

.gate__pad {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--space-2);
}

.gate__pad button {
  height: 48px;
  border: 0;
  border-radius: var(--radius-s);
  background: var(--tertiary-system-fill);
  color: var(--label);
  font: inherit;
  font-size: var(--text-title);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 640px) {
  .hourly {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .hourly .hour:last-child {
    display: none;
  }
}
