/* ============================================================
   Belvedere Heights Digital Notice Board
   Designed for 75" 4K TV (3840 x 2160)
   ============================================================ */

/* Reset & Base */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: 'Segoe UI', 'Microsoft YaHei', 'Microsoft JhengHei', sans-serif;
  background: #0a0a0a;
  color: #e0e0e0;
}

/* ============================================================
   TOP BANNER
   ============================================================ */
.top-banner {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 14px 0;
  background: linear-gradient(180deg, #1a1a3e 0%, #16213e 100%);
  border-bottom: 2px solid #e94560;
  flex-shrink: 0;
}

.banner-text {
  font-size: 2.4rem;
  font-weight: 700;
  color: #ffffff;
  letter-spacing: 1px;
  white-space: nowrap;
}

.banner-divider {
  font-size: 2.4rem;
  color: #e94560;
  font-weight: 300;
}

/* ============================================================
   NOTICE BOARD GRID LAYOUT
   8 columns x 3 rows for 4K (3840 x 2160)
   Row 1 (62fr): Weather | Events | Financials | Minutes
   Row 2 (14fr): Market Indices (right half) | YouTube (left half)
   Row 3 (24fr): RTHK News (right half) | YouTube (left half)
   Weather spans full height; YouTube spans rows 2-3 on the left
   ============================================================ */
body {
  display: flex;
  flex-direction: column;
}

.notice-board {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: 62fr 14fr 24fr;
  grid-template-areas:
    "weather  weather  events     events     financials  financials  minutes   minutes"
    "weather  weather  youtube    youtube    youtube     finance     finance   finance"
    "weather  weather  youtube    youtube    youtube     news        news      news";
  flex: 1;
  gap: 4px;
  padding: 4px;
  background: #111;
}

/* Grid area assignments */
.weather-panel    { grid-area: weather; }
.events-panel     { grid-area: events; }
.financials-panel { grid-area: financials; }
.minutes-panel    { grid-area: minutes; }
.finance-panel    { grid-area: finance; }
.news-panel       { grid-area: news; }
.youtube-panel    { grid-area: youtube; }

/* ============================================================
   GRID CELL COMMON STYLES
   ============================================================ */
.grid-cell {
  background: #1a1a2e;
  border: 1px solid #2a2a4a;
  border-radius: 6px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Panel Header */
.panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: linear-gradient(180deg, #16213e 0%, #1a1a2e 100%);
  border-bottom: 2px solid #e94560;
  flex-shrink: 0;
}

.header-icon {
  font-size: 2.1rem;
}

.header-title {
  font-size: 1.8rem;
  font-weight: 600;
  color: #ffffff;
  letter-spacing: 0.5px;
}

/* ============================================================
   WEATHER PANEL
   ============================================================ */
.weather-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  overflow: hidden;
}

.weather-main {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 10px 0;
}

.weather-temp {
  font-size: 8.4rem;
  font-weight: 700;
  color: #ffffff;
  line-height: 1;
}

.weather-icon {
  font-size: 7.2rem;
}

.weather-details {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 2.4rem;
}

.weather-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 4px;
}

.weather-row span:first-child {
  color: #888;
  white-space: pre-line;
}

.weather-row span:last-child {
  color: #e0e0e0;
  font-weight: 500;
}

/* Clock values — color overrides inside .weather-row */
.weather-row .clock-time {
  color: #fff;
  font-weight: 700;
  letter-spacing: 2px;
}

.weather-row .clock-date {
  color: #aaa;
}

.weather-row .holiday-text {
  color: #ffd700;
  font-weight: 500;
  text-align: right;
  white-space: pre-line;
}

.weather-row .clock-lunar {
  color: #c9a96e;
}

.weather-row .solar-term-text {
  color: #e0e0e0;
  font-weight: 500;
  text-align: right;
  white-space: pre-line;
}

/* Weather Warnings */
.weather-warnings {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.warning-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 20px;
  border-radius: 4px;
  font-size: 2.15rem;
  font-weight: 600;
  animation: warning-pulse 2s infinite;
}

.warning-badge.rain-red {
  background: #cc0000;
  color: #fff;
}

.warning-badge.rain-black {
  background: #000;
  color: #ff0;
  border: 2px solid #ff0;
}

.warning-badge.typhoon-t1 {
  background: #0066cc;
  color: #fff;
}

.warning-badge.typhoon-t3 {
  background: #ff6600;
  color: #fff;
}

.warning-badge.typhoon-t8,
.warning-badge.typhoon-t9,
.warning-badge.typhoon-t10 {
  background: #cc0000;
  color: #fff;
  animation: warning-pulse 0.5s infinite;
}

.warning-badge.default {
  background: #ff8800;
  color: #fff;
}

.warning-badge.warning-monsoon {
  background: #00897b;
  color: #fff;
}

/* Typhoon signal icons — official HKO images */
img.typhoon-sig {
  display: inline-block;
  flex-shrink: 0;
  height: 1em;
  width: auto;
  vertical-align: middle;
  image-rendering: auto;
}

/* Other HKO warning icons (hot, cold, rainstorm, etc.) */
img.hko-warn-icon {
  display: inline-block;
  flex-shrink: 0;
  height: 1em;
  width: auto;
  vertical-align: middle;
}

/* Warning badge: larger icon */
.warning-badge img.typhoon-sig,
.warning-badge img.hko-warn-icon {
  height: 2.2em;
}

/* Weather icon area: uniform size for all warning icons, 20% bigger */
.weather-icon img.typhoon-sig,
.weather-icon img.hko-warn-icon,
.weather-icon img.hko-wx-icon {
  height: 1.08em;
}

/* Add small gap between multiple weather icons */
.weather-icon {
  gap: 0.15em;
  display: inline-flex;
  align-items: center;
}

@keyframes warning-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* ============================================================
   PDF PANELS (Events, Financials, Minutes)
   ============================================================ */
.events-panel .panel-header,
.financials-panel .panel-header,
.minutes-panel .panel-header {
  justify-content: center;
}
.pdf-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #111;
  overflow: hidden;
  position: relative;
}

.pdf-container canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.pdf-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #555;
  font-size: 1.2rem;
  white-space: pre-line;
  text-align: center;
}

.pdf-page-indicator {
  padding: 6px 12px;
  text-align: center;
  font-size: 0.85rem;
  color: #888;
  background: rgba(0,0,0,0.3);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.pdf-flip-timer {
  color: #ff9800;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 50px;
  text-align: left;
}

/* ============================================================
   YAHOO FINANCE TICKER
   ============================================================ */
.finance-panel .panel-header {
  border-bottom-color: #4caf50;
}

.finance-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 0 12px;
  gap: 2px;
}

.finance-ticker-row {
  overflow: hidden;
  white-space: nowrap;
}

.finance-ticker {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  animation: scroll-finance 30s linear infinite;
  gap: 40px;
}

.finance-ticker:hover {
  animation-play-state: paused;
}

@keyframes scroll-finance {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.finance-item {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 2.64rem;
  flex-shrink: 0;
}

.finance-name {
  color: #aaa;
  font-size: 1.98rem;
}

.finance-price {
  color: #fff;
  font-weight: 700;
}

.finance-change {
  font-weight: 600;
  font-size: 2.2rem;
}

.finance-change.up {
  color: #4caf50;
}

.finance-change.down {
  color: #f44336;
}

.finance-updated {
  color: #555;
  font-size: 1.65rem;
  flex-shrink: 0;
  margin-left: 20px;
}

/* ============================================================
   RTHK NEWS PANEL
   ============================================================ */
.news-panel .panel-header {
  border-bottom-color: #2196F3;
}

.news-content {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: 4px 0;
}

.news-placeholder {
  color: #555;
  text-align: center;
  width: 100%;
  font-size: 1.5rem;
}

.news-ticker-row {
  overflow: hidden;
  white-space: nowrap;
  padding: 4px 0;
}

.news-ticker {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
  animation: scroll-news 80s linear infinite;
  gap: 40px;
  padding: 0 20px;
}

.news-ticker:hover {
  animation-play-state: paused;
}

@keyframes scroll-news {
  0%   { transform: translateX(0); }
  100% { transform: translateX(-50%); }
}

.news-item {
  color: #e0e0e0;
  font-size: 1.98rem;
  line-height: 1.3;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* News row 1: +15% taller */
.news-ticker-row:nth-child(1) .news-item {
  font-size: 2.28rem;
}

/* News row 2: +8% taller */
.news-ticker-row:nth-child(2) .news-item {
  font-size: 2.13rem;
}

/* News row 3: base */
.news-ticker-row:nth-child(3) .news-item {
  font-size: 1.98rem;
}

/* News row 4: -5% smaller */
.news-ticker-row:nth-child(4) .news-item {
  font-size: 1.88rem;
}

.news-item-img {
  position: relative;
}

.news-img {
  height: 70px;
  width: auto;
  max-width: 130px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
}

.news-title-text {
  position: relative;
  z-index: 1;
}

.news-bullet {
  color: #2196F3;
  font-size: 1.76rem;
  flex-shrink: 0;
}

.news-bullet.tc-bullet {
  color: #FF9800;
}

.news-time {
  color: #888;
  font-size: 1.54rem;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}

.news-timestamp {
  color: #555;
  font-size: 1.2rem;
  flex-shrink: 0;
  margin-left: 16px;
}

/* ============================================================
   YOUTUBE PANEL (Nostalgic Kowloon City)
   ============================================================ */
.youtube-panel .panel-header {
  border-bottom-color: #e94560;
}

.youtube-content {
  flex: 1;
  position: relative;
  background: #000;
  overflow: hidden;
}

.youtube-content iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

.youtube-placeholder {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #555;
  font-size: 1.2rem;
  white-space: pre-line;
  text-align: center;
  pointer-events: none;
}

.youtube-indicator {
  padding: 6px 12px;
  text-align: center;
  font-size: 0.85rem;
  color: #888;
  background: rgba(0,0,0,0.3);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.youtube-indicator span {
  color: #ff9800;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ============================================================
   REFRESH INDICATOR
   ============================================================ */
.refresh-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #0f0;
  display: inline-block;
  margin-left: auto;
  animation: refresh-blink 3s infinite;
}

@keyframes refresh-blink {
  0%, 80%, 100% { opacity: 1; }
  85%, 95% { opacity: 0.3; }
}

/* ============================================================
   RESPONSIVE FONT SCALING
   For 4K (3840x2160), the browser uses default scaling.
   All sizes above are tuned for this resolution.
   ============================================================ */

/* Error / no-data state */
.no-data {
  color: #666;
  text-align: center;
  padding: 20px;
  font-size: 3.3rem;
}

/* Smooth transitions for PDF page changes */
.pdf-container canvas {
  transition: opacity 0.5s ease;
}

/* ============================================================
   RESPONSIVE: HD / 1080p Screens (max-height: 1600px)
   Scales down root font-size so all rem-based sizes shrink ~25%
   for 1920x1080 and 2560x1440 displays
   ============================================================ */
@media (max-height: 1600px) {
  html {
    font-size: 12px;
  }

  /* Force exact row proportions and prevent overflow on HD */
  .notice-board {
    grid-template-rows: 62% 14% 24%;
    overflow: hidden;
  }

  .grid-cell {
    min-height: 0;
    overflow: hidden;
  }

  /* News ticker: scale down to ~60% */
  .news-content {
    gap: 6px;
    padding: 2px 0;
  }

  /* Weather: reduce font sizes for HD */
  .weather-temp {
    font-size: 4.5rem;
  }

  .weather-icon {
    font-size: 3.85rem;
  }

  .weather-details {
    font-size: 1.3rem;
  }

  .warning-badge {
    font-size: 1.15rem;
  }

  .news-ticker-row {
    padding: 2px 0;
  }

  .news-ticker {
    gap: 20px;
  }

  .news-item {
    font-size: 1.21rem;
    gap: 4px;
  }

  .news-bullet {
    font-size: 1.1rem;
  }

  .news-time {
    font-size: 0.94rem;
  }

  .news-timestamp {
    font-size: 0.7rem;
  }

  .news-img {
    height: 45px;
    max-width: 85px;
  }

  /* Finance ticker scaling for HD */
  .finance-item {
    font-size: 1.65rem;
    gap: 6px;
  }

  .finance-name {
    font-size: 1.21rem;
  }

  .finance-change {
    font-size: 1.38rem;
  }

  .finance-updated {
    font-size: 1.05rem;
  }
}

/* ============================================================
   RESPONSIVE: Phone / Tablet portrait (max-width: 1400px)
   Single column layout, scrollable, touch-friendly
   ============================================================ */
@media (max-width: 1400px) {
  html, body {
    overflow: auto;
    height: auto;
  }

  body {
    display: block;
  }

  /* Banner: stacked + smaller */
  .top-banner {
    flex-direction: column;
    gap: 6px;
    padding: 12px 10px;
    text-align: center;
  }

  .banner-text {
    font-size: 1.3rem;
    white-space: normal;
  }

  .banner-divider {
    display: none;
  }

  /* Grid: single column, auto height */
  .notice-board {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    height: auto;
  }

  /* Override grid-area assignments */
  .weather-panel,
  .events-panel,
  .financials-panel,
  .minutes-panel,
  .finance-panel,
  .news-panel,
  .youtube-panel {
    grid-area: auto;
    min-height: 400px;
    flex-shrink: 0;
  }

  /* News panel: allow more height for ticker rows on phone */
  .news-panel {
    min-height: 250px;
    max-height: 500px;
  }

  /* Slightly smaller panel headers */
  .panel-header {
    padding: 10px 14px;
    gap: 8px;
  }

  .header-icon {
    font-size: 1.4rem;
  }

  .header-title {
    font-size: 1.2rem;
  }

  /* Weather: scale for phone */
  .weather-content {
    padding: 14px;
    gap: 10px;
  }

  .weather-temp {
    font-size: 3.5rem;
  }

  .weather-icon {
    font-size: 3rem;
  }

  .weather-details {
    font-size: 1.1rem;
    gap: 6px;
  }

  .weather-row {
    padding: 6px 10px;
  }

  .warning-badge {
    font-size: 1rem;
    padding: 8px 12px;
  }

  /* PDF: indicator */
  .pdf-page-indicator {
    font-size: 0.9rem;
    padding: 6px 10px;
  }

  .pdf-placeholder {
    font-size: 1.1rem;
  }

  /* News ticker on phone */
  .news-content {
    gap: 8px;
    padding: 6px 0;
  }

  .news-ticker-row {
    padding: 4px 0;
  }

  .news-ticker {
    gap: 30px;
  }

  .news-item {
    font-size: 1.54rem;
    gap: 6px;
  }

  .news-bullet {
    font-size: 1.43rem;
  }

  .news-time {
    font-size: 1.21rem;
  }

  .news-timestamp {
    font-size: 0.9rem;
  }

  .news-img {
    height: 55px;
    max-width: 100px;
  }

  .news-placeholder {
    font-size: 1.2rem;
  }

  .no-data {
    font-size: 1rem;
    padding: 16px;
  }
}

/* Very small screens (max-width: 480px) */
@media (max-width: 480px) {
  .banner-text {
    font-size: 0.8rem;
  }

  .weather-temp {
    font-size: 1.6rem;
  }

  .header-title {
    font-size: 0.75rem;
  }

  .weather-panel,
  .events-panel,
  .financials-panel,
  .minutes-panel,
  .finance-panel,
  .youtube-panel {
    min-height: 220px;
  }
}
