/* css/widgets.css — Sonoma-style desktop widget column. Owned by Dev W.
   Rendered into <div id="widgets-root"> (positioned by css/main.css: fixed,
   left edge, under app windows, click-through). .tb-widgets re-enables
   pointer events for the column. All classes tb- prefixed, everything
   scoped under #widgets-root. */

/* ---------- grid container ---------- */

/* One aligned column: equal 160px tiles, with shared 16px gutters. */
#widgets-root .tb-widgets {
  display: grid;
  width: var(--tb-widget-column);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--tb-widget-gap);
  align-items: stretch;
  pointer-events: auto;
}

/* Phones: the widget grid fills the column. */
@media (max-width: 768px) {
  #widgets-root .tb-widgets {
    width: 100%;
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---------- shared card chrome (every widget, small or wide) ---------- */

:is(#widgets-root, #promo-root) .tb-widget {
  --tb-widget-radius: 28px;
  box-sizing: border-box;
  background: rgba(28, 28, 30, 0.55);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--tb-widget-radius);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.3);
  color: #fff;
  padding: 16px;
  text-align: left;
  overflow: hidden;
}

#widgets-root .tb-widget--wide {
  grid-column: span 2;
}

/* ---------- 1. calendar ---------- */

#widgets-root .tb-cal-weekday {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #ff3b30; /* macOS Calendar red */
}

#widgets-root .tb-cal-day {
  margin-top: 2px;
  font-size: 40px;
  font-weight: 200;
  line-height: 1.05;
}

#widgets-root .tb-cal-tomorrow {
  margin-top: 8px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.5);
}

#widgets-root .tb-cal-event {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
  min-width: 0;
}

#widgets-root .tb-cal-event-emoji {
  flex: 0 0 auto;
  font-size: 11px;
}

#widgets-root .tb-cal-event-text {
  flex: 0 1 auto;
  min-width: 0;
  font-size: 11px;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- 2. weather (live, static fallback) ---------- */

/* Live cards anchor the tiny "offline" badge bottom-right. */
#widgets-root .tb-widget--weather,
#widgets-root .tb-widget--stocks {
  position: relative;
}

#widgets-root .tb-widget-note {
  position: absolute;
  right: 10px;
  bottom: 8px;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.45);
}

#widgets-root .tb-weather-city {
  font-size: 15px;
  font-weight: 600;
}

#widgets-root .tb-weather-temp {
  margin-top: 2px;
  font-size: 40px;
  font-weight: 200;
  line-height: 1.1;
}

#widgets-root .tb-weather-icon {
  margin-top: 2px;
  font-size: 20px;
  line-height: 1.2;
}

#widgets-root .tb-weather-cond {
  margin-top: 2px;
  font-size: 12px;
}

#widgets-root .tb-weather-hilo {
  margin-top: 2px;
  font-size: 12px;
  color: #ccc;
}

/* ---------- 3. world clock (wide) ---------- */

#widgets-root .tb-clock-cities {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px 4px;
}

#widgets-root .tb-clock-city {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 0;
}

/* Local daytime uses a white dial; local nighttime uses a black dial. */
#widgets-root .tb-clock-face {
  --tb-clock-radius: 25px;
  --tb-clock-surface: #1c1c1e;
  --tb-clock-numerals: rgba(255, 255, 255, 0.85);
  --tb-clock-hands: #fff;
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--tb-clock-surface);
  text-shadow: none;
}

#widgets-root .tb-clock-face[data-period="day"] {
  --tb-clock-surface: #fff;
  --tb-clock-numerals: #1c1c1e;
  --tb-clock-hands: #1c1c1e;
}

/* Numerals stay upright: translate to center, swing out, counter-rotate. */
#widgets-root .tb-clock-num {
  position: absolute;
  top: 50%;
  left: 50%;
  font-size: 8px;
  font-weight: 500;
  line-height: 1;
  color: var(--tb-clock-numerals);
}

/* Hands pivot on their bottom edge at the face center; js sets the angle
   as `translateX(-50%) rotate(Ndeg)`. */
#widgets-root .tb-clock-hand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  transform: translateX(-50%);
  transform-origin: bottom center;
  border-radius: 2px;
}

#widgets-root .tb-clock-hand--hour {
  width: 4px;
  height: 30%;
  background: var(--tb-clock-hands);
}

#widgets-root .tb-clock-hand--minute {
  width: 2.5px;
  height: 44%;
  background: var(--tb-clock-hands);
}

#widgets-root .tb-clock-hand--second {
  width: 1px;
  height: 46%;
  background: #ff9f0a; /* macOS orange sweep */
}

#widgets-root .tb-clock-dot {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #ff9f0a;
  transform: translate(-50%, -50%);
}

#widgets-root .tb-clock-name {
  margin-top: 8px;
  font-size: 11px;
  color: #fff;
  white-space: normal;
  line-height: 13px;
  min-height: 26px;
  display: flex;
  align-items: center;
  text-align: center;
  max-width: 100%;
}

#widgets-root .tb-clock-today {
  margin-top: 1px;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.5);
}

#widgets-root .tb-clock-offset {
  margin-top: 1px;
  font-size: 9px;
  color: rgba(255, 255, 255, 0.5);
}

@media (max-width: 768px) {
  #widgets-root .tb-clock-face {
    --tb-clock-radius: 18px;
    width: 48px;
    height: 48px;
  }
}

/* ---------- 4. stock watchlist ---------- */

#widgets-root .tb-stocks-header { touch-action: none; display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; }
#widgets-root .tb-stocks-title { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: -.2px; }
#widgets-root .tb-stocks-currency { font-size: 10px; color: rgba(255,255,255,.68); }
#widgets-root .tb-stocks-list { border-radius: 4px; }
#widgets-root .tb-stocks-row { display: grid; grid-template-columns: minmax(0,1fr) 63px 64px; align-items: center; gap: 8px; min-height: 31px; }
#widgets-root .tb-stocks-row + .tb-stocks-row { border-top: 1px solid rgba(255,255,255,.08); }
#widgets-root .tb-stock-company { display: flex; align-items: baseline; flex-wrap: wrap; column-gap: 6px; line-height: 1.25; min-width: 0; padding: 5px 0; }
#widgets-root .tb-stock-name { font-size: 11px; font-weight: 600; }
#widgets-root .tb-stock-symbol { font-size: 9px; color: rgba(255,255,255,.6); }
#widgets-root .tb-market-price, #widgets-root .tb-market-change { font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
#widgets-root .tb-market-price { font-size: 12px; font-weight: 500; }
#widgets-root .tb-market-change { font-size: 10px; color: rgba(255,255,255,.6); }
#widgets-root .tb-market-change--up { color: #48e879; }
#widgets-root .tb-market-change--down { color: #ff7169; }
#widgets-root .tb-market-change--flat { color: rgba(255,255,255,.85); }
#widgets-root .tb-stocks-row[data-quote-status="stale"] .tb-market-price::before { content: '· '; color: #ffd166; }
#widgets-root .tb-stocks-row[data-quote-status="unavailable"] .tb-market-change { font-size: 9px; }
#widgets-root .tb-stocks-divider { height: 1px; margin: 10px 0 8px; background: rgba(255,255,255,.22); }
#widgets-root .tb-market-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
#widgets-root .tb-stocks-source, #widgets-root .tb-market-updated, #widgets-root .tb-stocks-status { font-size: 9px; line-height: 1.4; color: rgba(255,255,255,.68); }
#widgets-root .tb-stocks-source { text-decoration: none; }
#widgets-root .tb-stocks-source:hover { color: #fff; text-decoration: underline; }
#widgets-root .tb-stocks-status { margin-top: 3px; }

/* ---------- 5. office invitation ---------- */
/* Targeted contact-card redesign: DESIGN_VARIANCE 2, MOTION_INTENSITY 4,
   VISUAL_DENSITY 5. Existing web Liquid DOM and drag spring are preserved. */
#promo-root .tb-widget--visit {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  align-items: start;
  justify-self: start;
  align-self: flex-start;
  width: fit-content;
  max-width: 100%;
  gap: 12px;
  min-height: 110px;
}
#promo-root .tb-visit-marker {
  display: grid;
  place-items: center;
  width: 32px;
  height: 40px;
}
#promo-root .tb-visit-icon {
  display: block;
  width: 32px;
  height: 40px;
  object-fit: contain;
}
#promo-root .tb-visit-content { min-width: 0; }
#promo-root .tb-visit-title {
  margin: 0;
  font: 600 14px/18px var(--tb-font);
  letter-spacing: -.15px;
}
#promo-root .tb-visit-address {
  margin: 4px 0 0;
  font-style: normal;
  font-size: 11.5px;
  line-height: 16px;
  color: rgba(255,255,255,.88);
}
#promo-root .tb-visit-address span { display: block; }
#promo-root .tb-visit-map-link {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  color: #f7fbff;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 18px;
  white-space: nowrap;
  text-decoration: underline;
  text-decoration-color: rgba(255,255,255,.5);
  text-underline-offset: 3px;
  border-radius: 3px;
}
#promo-root .tb-visit-map-link:hover { text-decoration-color: currentColor; }
#promo-root .tb-visit-map-link:active { opacity: .75; }
#promo-root .tb-visit-map-link:focus-visible {
  outline: 2px solid #a9d5ff;
  outline-offset: 4px;
}
#promo-root .tb-visit-arrow { font-size: 14px; text-decoration: none; }

/* Give the full watchlist its own column on shorter, wide desktops. */
@media (min-width: 1100px) and (max-height: 1200px) {
  #widgets-root .tb-widgets {
    width: calc(var(--tb-widget-column) * 2 + var(--tb-widget-gap));
    grid-template-columns: repeat(4, minmax(0, 1fr));
    align-items: start;
  }
  #widgets-root .tb-widget--cal { grid-column: 1; grid-row: 1; }
  #widgets-root .tb-widget--weather { grid-column: 2; grid-row: 1; }
  #widgets-root .tb-widget--clock { grid-column: 1 / span 2; grid-row: 2; }
  #widgets-root .tb-widget--stocks { grid-column: 3 / span 2; grid-row: 1 / span 3; }
}

/* Compact spacing on shorter laptop displays; all stock rows remain visible. */
@media (min-width: 769px) and (max-height: 860px) {
  #widgets-root { --tb-widget-gap: 12px; top: calc(var(--tb-menubar-h) + 12px); }
  :is(#widgets-root, #promo-root) .tb-widget { padding: 8px 16px; }
  #widgets-root .tb-weather-temp,
  #widgets-root .tb-cal-day { font-size: 34px; }
  #widgets-root .tb-weather-icon { font-size: 18px; }
  #widgets-root .tb-clock-cities { row-gap: 12px; }
  #widgets-root .tb-clock-face { width: 48px; height: 48px; --tb-clock-radius: 18px; }
  #widgets-root .tb-clock-name { margin-top: 6px; font-size: 10px; line-height: 12px; min-height: 24px; }
  #widgets-root .tb-clock-today,
  #widgets-root .tb-clock-offset { font-size: 8px; }
  #promo-root .tb-widget--visit { min-height: 94px; }
}

/* ---------- phones: hide the whole column ---------- */

/* ≤768px: the widget gallery is desktop-only, macOS-style — a phone screen
   has no room for a 330px column, so the entire column is hidden instead of
   squeezed. (#widgets-root itself is transparent + click-through via
   main.css, so hiding the grid removes everything visible; no inner widget
   is independently position:fixed.) */
@media (max-width: 768px) {
  #widgets-root .tb-widgets {
    display: none;
  }
}
