/* =====================================================
   DSEG フォント定義
   ===================================================== */
@font-face {
  font-family: 'DSEG7Classic';
  src: url('../fonts/DSEG/DSEG7Classic-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'DSEG14Classic';
  src: url('../fonts/DSEG/DSEG14Classic-Regular.woff2') format('woff2');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* =====================================================
   カスタムプロパティ（Blue LED テーマ）
   ===================================================== */
:root {
  --bg:           #040812;
  --led-on:       #00d4ff;
  --led-dim:      #001828;
  --led-mid:      #005580;
  --glow-near:    rgba(0, 212, 255, 0.85);
  --glow-mid:     rgba(0, 180, 230, 0.45);
  --glow-far:     rgba(0, 140, 200, 0.20);

  --sep-color:    #00aad4;
  --date-color:   #0099bb;
  --weekday-color:#00ccee;
  --temp-high:    #ff8866;
  --temp-low:     #66ccff;
  --pop-color:    #88bbff;
  --footer-color: #005577;

  --font-7seg:    'DSEG7Classic', 'Courier New', monospace;
  --font-14seg:   'DSEG14Classic', 'Courier New', monospace;
  --font-ui:      'Helvetica Neue', Arial, 'Hiragino Sans', 'Yu Gothic', sans-serif;
}

/* =====================================================
   リセット・ベース
   ===================================================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  background: #000;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

/* =====================================================
   アプリコンテナ（5:4 アスペクト比）
   ===================================================== */
.app-container {
  width: min(100vw, 125vh);
  aspect-ratio: 5 / 4;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  container-type: inline-size;
  container-name: app;
  overflow: hidden;
  /* サブピクセル境界を避ける */
  border-radius: 0;
  position: relative;
}

/* =====================================================
   時計エリア（上 58%）
   ===================================================== */
.clock-section {
  flex: 58 58 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1cqi 2cqi 0.5cqi;
  gap: 1cqi;
}

/* ----- 時刻行 ----- */
.time-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.15cqi;
  line-height: 1;
  font-size: 13cqi;
}

/* 非アクティブ・セグメント（下地） */
.d-bg {
  display: block;
  font-family: var(--font-7seg);
  color: var(--led-dim);
  user-select: none;
  pointer-events: none;
  font-size: inherit;
  line-height: 1;
}

/* アクティブ・セグメント（前景） */
.digit-slot {
  position: relative;
  display: inline-block;
  line-height: 1;
}

.d-fg {
  font-family: var(--font-7seg);
  color: var(--led-on);
  text-shadow:
    0 0 4px  var(--glow-near),
    0 0 12px var(--glow-near),
    0 0 24px var(--glow-mid),
    0 0 48px var(--glow-far);
  position: absolute;
  inset: 0;
  font-size: inherit;
  line-height: 1;
}

/* 秒の桁: 少し小さく */
.digit-slot--s {
  font-size: 0.72em;
  align-self: flex-end;
  margin-bottom: 0.07em;
}

/* コロン区切り */
.time-sep {
  font-family: var(--font-7seg);
  color: var(--sep-color);
  text-shadow:
    0 0 6px  rgba(0, 200, 220, 0.8),
    0 0 16px rgba(0, 170, 210, 0.4);
  animation: blink-sep 1s step-start infinite;
  line-height: 1;
  padding: 0 0.05cqi;
  align-self: center;
  margin-bottom: 0.05em;
}

.time-sep--s {
  font-size: 0.72em;
  align-self: flex-end;
  margin-bottom: 0.07em;
  padding: 0 0.03cqi;
}

@keyframes blink-sep {
  50% { opacity: 0.08; }
}

/* ----- 日付行 ----- */
.date-row {
  display: flex;
  align-items: baseline;
  gap: 0.8cqi;
  font-size: 3.6cqi;
}

.date-seg {
  font-family: var(--font-14seg);
  color: var(--date-color);
  text-shadow:
    0 0 6px  rgba(0, 153, 187, 0.7),
    0 0 18px rgba(0, 120, 160, 0.35);
  letter-spacing: 0.05em;
}

.date-weekday {
  font-family: var(--font-ui);
  color: var(--weekday-color);
  font-size: 0.85em;
  font-weight: 300;
  text-shadow: 0 0 8px rgba(0, 200, 240, 0.5);
  letter-spacing: 0.05em;
}

/* =====================================================
   天気エリア（下 42%）
   ===================================================== */
.weather-section {
  flex: 42 42 0;
  display: flex;
  flex-direction: column;
  padding: 0 2cqi 1cqi;
  border-top: 1px solid rgba(0, 100, 140, 0.3);
  box-shadow: inset 0 1px 0 rgba(0, 180, 255, 0.05);
}

/* ----- 予報カード列 ----- */
.weather-cards {
  flex: 1 1 0;
  display: flex;
  align-items: stretch;
  gap: 1cqi;
  overflow: hidden;
}

.weather-card {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-evenly;
  padding: 1cqi 0.5cqi;
  border: 1px solid rgba(0, 100, 160, 0.25);
  border-radius: 0.5cqi;
  background: rgba(0, 20, 40, 0.4);
  position: relative;
  overflow: hidden;
}

/* 光沢ライン */
.weather-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0, 180, 255, 0.3), transparent);
}

/* 今日カード: 少し明るい */
.weather-card.today {
  border-color: rgba(0, 160, 220, 0.45);
  background: rgba(0, 30, 55, 0.5);
}

.wc-date {
  font-family: var(--font-ui);
  color: var(--date-color);
  font-size: 2.5cqi;
  letter-spacing: 0.03em;
}

.weather-card.today .wc-date {
  color: var(--led-on);
  text-shadow: 0 0 8px rgba(0, 212, 255, 0.4);
}

.wc-icon {
  font-size: 5.5cqi;
  line-height: 1;
  filter: drop-shadow(0 0 4px rgba(0, 180, 255, 0.3));
}

.wc-temp {
  display: flex;
  gap: 1.2cqi;
  align-items: baseline;
  font-family: var(--font-7seg);
  font-size: 3cqi;
}

.temp-high {
  color: var(--temp-high);
  text-shadow: 0 0 6px rgba(255, 136, 102, 0.5);
}

.temp-low {
  color: var(--temp-low);
  text-shadow: 0 0 6px rgba(102, 204, 255, 0.5);
}

.wc-pop {
  font-family: var(--font-ui);
  color: var(--pop-color);
  font-size: 2.2cqi;
  letter-spacing: 0.03em;
}

/* ローディング表示 */
.weather-loading {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--footer-color);
  font-family: var(--font-ui);
  font-size: 2.5cqi;
  letter-spacing: 0.1em;
}

/* ----- フッター ----- */
.weather-footer {
  display: flex;
  align-items: center;
  gap: 1.2cqi;
  padding-top: 0.5cqi;
  height: 4cqi;
}

.last-update {
  font-family: var(--font-ui);
  color: var(--footer-color);
  font-size: 2cqi;
  letter-spacing: 0.05em;
  min-width: 5.5cqi;
}

.refresh-btn {
  background: none;
  border: 1px solid rgba(0, 100, 140, 0.4);
  color: var(--footer-color);
  font-size: 2.2cqi;
  width: 4cqi;
  height: 4cqi;
  border-radius: 0.4cqi;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.2s, border-color 0.2s, text-shadow 0.2s;
  line-height: 1;
  flex-shrink: 0;
}

.refresh-btn:hover:not(:disabled) {
  color: var(--led-on);
  border-color: var(--led-on);
  text-shadow: 0 0 6px rgba(0, 212, 255, 0.6);
}

.refresh-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.fetch-status {
  font-family: var(--font-ui);
  font-size: 1.8cqi;
  color: var(--footer-color);
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fetch-status.status-error {
  color: #ff6644;
  text-shadow: 0 0 4px rgba(255, 80, 40, 0.4);
}

/* =====================================================
   スキャンライン オーバーレイ（雰囲気演出）
   ===================================================== */
.app-container::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.06) 2px,
    rgba(0, 0, 0, 0.06) 4px
  );
  pointer-events: none;
  z-index: 10;
}

/* =====================================================
   縦長（ポートレート）対応
   ===================================================== */
@media (orientation: portrait) {
  .app-container {
    width: 100vw;
    height: 80vw;
    aspect-ratio: 5 / 4;
  }
}
