/* Glance Live — visual spec aligned to Figma file Kz2HzfobkzozSoCKLBEU2J / node 1:2 */

:root {
  --bg: #ffffff;
  --fg: #000000;
  --fg-muted: #6a6a6a;
  --fg-faint: #a9a9a9;
  --hairline: #e2e2e2;
  --gray-soft: #f0f0f0;
  --gray-pill: #eeeeee;
  --active-bg: rgba(0, 0, 0, 0.84);

  /* Category palette: pastel bg + saturated text */
  --cat-politics-bg: #e5f0e8;
  --cat-politics-fg: #1a5c2a;
  --cat-economy-bg: #e8ebf5;
  --cat-economy-fg: #1a2580;
  --cat-academic-bg: #e8f0f5;
  --cat-academic-fg: #1a4080;
  --cat-tech-bg: #f0eaf5;
  --cat-tech-fg: #4a1a80;
  --cat-sports-bg: #fce8e8;
  --cat-sports-fg: #801a1a;
  --cat-culture-bg: #f5e8ec;
  --cat-culture-fg: #801a4a;
  --cat-other-bg: #eeeeee;
  --cat-other-fg: #4a4a4a;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", Helvetica, Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-geist: "Geist", "Inter", -apple-system, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11", "ss01";
}

a { color: inherit; }
button { font-family: inherit; }

/* App layout — 1440 canvas: sidebar 308 (24+260+24) + main 1132 */
#app {
  display: grid;
  grid-template-columns: 308px 1fr;
  max-width: 1440px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  padding: 32px 24px;
  border-right: 1px solid var(--hairline);
  display: flex;
  flex-direction: column;
}

/* Brand: 64px black square + 40px ExtraBold GLANCE */
.brand {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 32px;
}
.brand-mark {
  width: 64px;
  height: 64px;
  background: #000;
  border-radius: 12.8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
}
.brand-mark svg { width: 34px; height: 34px; display: block; }
.brand-wordmark {
  font-family: var(--font-sans);
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -2px;
  line-height: 1.5;
  color: #000;
}

/* Date stack */
.date-day {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 2.16px;
  color: var(--fg-faint);
  margin: 0;
  text-transform: uppercase;
}
.date-num {
  font-size: 64px;
  font-weight: 700;
  letter-spacing: -2.56px;
  color: var(--fg);
  margin: 8px 0 0;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.date-month {
  font-size: 20px;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--fg-muted);
  margin: 8px 0 0;
  text-transform: uppercase;
}

hr {
  border: none;
  border-top: 1px solid var(--hairline);
  margin: 24px 0;
}

/* Calendar */
.calendar { margin: 0; }
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  margin-bottom: 24px;
}
.cal-title {
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 1.08px;
  text-transform: uppercase;
  color: var(--fg-muted);
}
.cal-nav {
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--gray-soft);
  cursor: pointer;
  color: var(--fg-muted);
  font-size: 16px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  padding: 0;
}
.cal-nav:hover { background: #e6e6e6; color: var(--fg); }

.cal-dow {
  display: grid;
  grid-template-columns: repeat(7, 37px);
  height: 20px;
  margin-bottom: 8px;
}
.cal-dow span {
  font-size: 16px;
  font-weight: 500;
  letter-spacing: 0.64px;
  color: var(--fg-faint);
  text-align: center;
  line-height: 20px;
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 37px);
  grid-auto-rows: 34px;
  row-gap: 8px;
}
.cal-day {
  position: relative;
  width: 37px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 400;
  color: var(--fg-muted);
  background: none;
  border: none;
  border-radius: 7px;
  cursor: default;
  padding: 0;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
}
.cal-day.is-past-no-briefing { color: var(--fg-faint); }
.cal-day.has-briefing {
  color: var(--fg);
  cursor: pointer;
}
.cal-day.has-briefing:hover { background: var(--gray-soft); }
.cal-day.has-briefing::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--fg);
}
.cal-day.is-current {
  background: #000;
  color: #fff;
  font-weight: 700;
}
.cal-day.is-current.has-briefing::after { background: #fff; }
.cal-day.is-current:hover { background: #000; }
.cal-day.is-empty { visibility: hidden; }

.meta {
  font-size: 13px;
  color: var(--fg-faint);
  margin: 0;
}

.clock {
  margin-top: auto;
  padding-top: 24px;
  font-size: 20px;
  letter-spacing: 1px;
  color: var(--fg-faint);
  font-variant-numeric: tabular-nums;
}

/* ---------- Main ---------- */
.main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.filter-bar {
  height: 57px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 14px 36px;
  flex-shrink: 0;
}

/* Pill tabs */
.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 15px;
  border: 1px solid var(--hairline);
  background: transparent;
  border-radius: 100px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--fg-muted);
  cursor: pointer;
  white-space: nowrap;
  line-height: 1;
  height: 33px;
}
.tab:hover { color: var(--fg); border-color: #c8c8c8; }
.tab[aria-selected="true"] {
  background: var(--active-bg);
  border-color: var(--active-bg);
  color: #fff;
  font-weight: 600;
}
.tab-icon {
  width: 13px;
  height: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: inherit;
}
.tab-icon svg {
  width: 13px;
  height: 13px;
  display: block;
  color: inherit;
}

/* Spacer pushes lang toggle to the right */
.tabs {
  display: flex;
  align-items: center;
  gap: 7px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

/* Lang toggle: outer pill + two inner pills */
.lang-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--gray-pill);
  border: 1px solid var(--hairline);
  border-radius: 100px;
  flex-shrink: 0;
  height: 28px;
  padding: 0;
}
.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  height: 100%;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.12px;
  color: var(--fg-muted);
  background: transparent;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  line-height: 1;
}
.lang-btn[data-lang="en"] {
  font-family: var(--font-geist);
}
.lang-btn[aria-pressed="true"] {
  background: var(--active-bg);
  color: #fff;
}

.bar-rule {
  margin: 0;
  height: 1px;
  background: var(--hairline);
  border: none;
}

/* Cards grid: 2 columns, gap 20, padding 36 */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 520px);
  gap: 24px 20px;
  padding: 29px 36px 32px;
  justify-content: start;
}

.card {
  position: relative;
  width: 520px;
  min-height: 293px;
  background: var(--bg);
  border: 1px solid var(--hairline);
  border-radius: 14px;
  padding: 24px;
  overflow: hidden;
}
.cards-grid .card:nth-child(n+5) { min-height: 317px; } /* last row taller per Figma */

.card[data-state="failed"] {
  background: #fafafa;
}
.card[data-state="failed"] .card-headline,
.card[data-state="failed"] .card-summary {
  color: var(--fg-muted);
}

/* Source mark — img when brand logo available, text label as fallback */
.card-source {
  display: inline-block;
  height: 16px;
  max-width: 180px;
  line-height: 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg);
  vertical-align: top;
}
img.card-source {
  width: auto;
  letter-spacing: 0;
  text-transform: none;
  font-weight: normal;
}

.card-badge {
  position: absolute;
  top: 24px;
  right: 24px;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-family: var(--font-geist);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.4px;
  background: var(--cat-other-bg);
  color: var(--cat-other-fg);
  line-height: 13px;
  white-space: nowrap;
}
.card-badge[data-cat="Politics"] { background: var(--cat-politics-bg); color: var(--cat-politics-fg); }
.card-badge[data-cat="Economy"]  { background: var(--cat-economy-bg);  color: var(--cat-economy-fg);  }
.card-badge[data-cat="Academic"] { background: var(--cat-academic-bg); color: var(--cat-academic-fg); }
.card-badge[data-cat="Tech"]     { background: var(--cat-tech-bg);     color: var(--cat-tech-fg);     }
.card-badge[data-cat="Sports"]   { background: var(--cat-sports-bg);   color: var(--cat-sports-fg);   }
.card-badge[data-cat="Culture"]  { background: var(--cat-culture-bg);  color: var(--cat-culture-fg);  }

.card-time {
  font-size: 12px;
  font-weight: 400;
  color: var(--fg-faint);
  margin: 9px 0 0;
}

.card-headline {
  display: block;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.4px;
  line-height: 1.5;
  color: var(--fg);
  text-decoration: none;
  margin: 8px 0 0;
}
.card-headline:hover { color: var(--fg-muted); }

.card-summary {
  font-size: 16px;
  font-weight: 400;
  letter-spacing: -0.16px;
  line-height: 1.5;
  color: var(--fg-muted);
  margin: 12px 0 0;
}

.card-status-tag {
  position: absolute;
  bottom: 16px;
  right: 16px;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--fg-faint);
}

.footer {
  padding: 0 36px 32px;
  font-size: 11px;
  color: var(--fg-faint);
}
.footer p { margin: 0; }
.footer a {
  color: var(--fg-muted);
  text-decoration: none;
  border-bottom: 1px solid var(--hairline);
}
.footer a:hover { color: var(--fg); border-color: var(--fg); }

/* ---------- Error / fallback ---------- */
.error-state {
  padding: 96px 32px;
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
  color: var(--fg-muted);
  font-size: 15px;
}
.error-state a {
  color: var(--fg);
  border-bottom: 1px solid var(--hairline);
  text-decoration: none;
}
.error-state a:hover { border-color: var(--fg); }

.noscript {
  padding: 64px 32px;
  text-align: center;
  color: var(--fg-muted);
}

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
    padding: 24px;
  }
  .card { width: 100%; }
  .filter-bar { padding: 14px 24px; }
  .footer { padding: 0 24px 32px; }
}

@media (max-width: 880px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  #app {
    grid-template-columns: 1fr;
  }
  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--hairline);
    padding: 20px;
  }
  .brand { margin-bottom: 20px; gap: 12px; }
  .brand-mark { width: 44px; height: 44px; border-radius: 9px; }
  .brand-mark svg { width: 24px; height: 24px; }
  .brand-wordmark { font-size: 28px; letter-spacing: -1.4px; }
  .date-day { font-size: 14px; letter-spacing: 1.5px; }
  .date-num { font-size: 44px; letter-spacing: -1.7px; }
  .date-month { font-size: 14px; }
  .calendar, .clock { display: none; }
  .sidebar hr { display: none; }
  .meta { margin-top: 12px; }
  .filter-bar {
    height: auto;
    padding: 12px 20px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .tabs { flex-wrap: wrap; }
  .cards-grid { padding: 16px 20px 24px; gap: 16px; }
  .card { min-height: 0; padding: 20px; }
  .cards-grid .card:nth-child(n+5) { min-height: 0; }
  .card-badge { top: 20px; right: 20px; }
  .card-headline { font-size: 18px; }
  .card-summary { font-size: 14px; }
  .footer { padding: 16px 20px 24px; }
}
