/* Document defaults, wallpaper, and the shared widget-card component. */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  height: 100%;
  background: var(--wallpaper);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  margin: 0;
  min-height: 100%;
  background: var(--wallpaper);
  color: var(--label);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: var(--leading-snug);
  font-weight: var(--weight-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
p,
ul {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

.wallpaper {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 52% 46% at 6% -8%, var(--orb-blue), transparent 68%),
    radial-gradient(ellipse 48% 42% at 104% 108%, var(--orb-orange), transparent 70%),
    radial-gradient(ellipse 34% 32% at 82% 8%, var(--orb-pink), transparent 72%),
    radial-gradient(ellipse 36% 30% at 42% 112%, var(--orb-purple), transparent 70%),
    var(--wallpaper);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.noscript {
  position: relative;
  z-index: 1;
  margin: var(--space-6);
}

/*
  Widget card.
  Sizes change density, not the grid placement (that lives in layout.css).
  small  — one primary metric (Tesla)
  medium — a metric plus a short series (weather, shopping)
  large  — a primary block plus a list (calendar, kids)
*/
.widget {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: var(--space-4);
  border: 1px solid var(--widget-stroke);
  border-radius: var(--radius-widget);
  background: var(--widget-fill);
  box-shadow: var(--widget-shadow), var(--widget-highlight);
  backdrop-filter: var(--material-regular);
  -webkit-backdrop-filter: var(--material-regular);
}

.widget--small {
  padding: var(--space-3) var(--space-4);
}

.widget--large {
  padding: var(--space-4) var(--space-5);
}

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

/*
  1024×768 gives the middle column about 60px for "Granada" / "Model Y"
  once "Actualizado HH:MM" shares the row, so WebKit ellipsizes the title.
  Move that stamp onto its own line at this narrow landscape size.
  1194×834, 1366×1024, and portrait keep a single row.
*/
@media (max-width: 1100px) and (max-height: 820px) and (orientation: landscape) {
  .widget--weather .widget__head,
  .widget--tesla .widget__head {
    flex-wrap: wrap;
    row-gap: 0;
  }

  .widget--weather .widget__updated,
  .widget--tesla .widget__updated {
    flex: 1 0 100%;
    margin-left: 0;
    text-align: right;
  }
}

.widget__glyph {
  display: grid;
  place-items: center;
  width: clamp(22px, 1.15vw + 0.9vh, 30px);
  height: clamp(22px, 1.15vw + 0.9vh, 30px);
  flex: none;
  border-radius: 7px;
  background: var(--widget-tint, var(--system-blue));
  color: var(--on-tint);
}

.widget__glyph svg {
  width: 14px;
  height: 14px;
  display: block;
}

.widget__title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-subhead);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.01em;
  color: var(--secondary-label);
}

.widget__updated {
  margin-left: auto;
  flex: none;
  color: var(--tertiary-label);
  font-size: var(--text-footnote);
  font-weight: var(--weight-medium);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.net-status {
  position: fixed;
  z-index: 4;
  top: calc(10px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  padding: 4px 14px;
  border-radius: var(--radius-pill);
  background: var(--system-red);
  color: #fff;
  font-size: var(--text-subhead);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  box-shadow: var(--shadow-md);
}

.net-status[hidden] {
  display: none;
}

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

.widget__loading,
.widget__empty {
  margin: auto 0;
  color: var(--secondary-label);
  font-size: var(--text-callout);
}

.widget__hint {
  margin-top: var(--space-2);
  color: var(--tertiary-label);
  font-size: var(--text-footnote);
}

.widget--calendar { --widget-tint: var(--system-red); }
.widget--weather { --widget-tint: var(--system-blue); }
.widget--tesla { --widget-tint: var(--system-red); }
.widget--shopping { --widget-tint: var(--system-orange); }
.widget--kids { --widget-tint: var(--system-purple); }

.toast {
  position: fixed;
  z-index: 5;
  left: 50%;
  bottom: calc(var(--space-4) + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  max-width: calc(100% - 32px);
  padding: 10px 10px 10px 16px;
  border: 1px solid var(--widget-stroke);
  border-radius: var(--radius-pill);
  background: var(--toast-fill);
  box-shadow: var(--shadow-lg);
  backdrop-filter: var(--material-thick);
  -webkit-backdrop-filter: var(--material-thick);
}

.toast[hidden] {
  display: none;
}

.toast__text {
  font-size: var(--text-subhead);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.toast__action {
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--system-blue);
  color: var(--on-tint);
  padding: 8px 14px;
  font-size: var(--text-subhead);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}

.toast__action:focus-visible,
.task:focus-visible {
  outline: 3px solid var(--system-blue);
  outline-offset: 2px;
}

@media (prefers-reduced-transparency: reduce) {
  .widget,
  .toast {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
    background: var(--widget-fill-solid);
  }
}

@media (prefers-contrast: more) {
  .widget {
    background: var(--widget-fill-solid);
    border-color: var(--label);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}
