/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  max-width: 100%;
}

body {
  font-family: -apple-system, 'Hiragino Sans', 'Yu Gothic UI', 'Meiryo', sans-serif;
  min-height: 100vh;
  background: linear-gradient(160deg, #1565C0 0%, #42A5F5 100%);
  color: #fff;
  transition: background 1.2s ease, color 1.2s ease;
  overflow-x: hidden;
}

body.night {
  background: linear-gradient(160deg, #0a0e1a 0%, #1a237e 100%);
}

body.cloudy {
  background: linear-gradient(160deg, #455A64 0%, #78909C 100%);
}

body.midnight {
  background: linear-gradient(160deg, #000000 0%, #000008 100%);
  color: rgba(255,255,255,0.08);
}

body.midnight .hero-clock {
  color: rgba(255,255,255,0.92);
  border-bottom-color: rgba(255,255,255,0.06);
}

body.midnight .hero-box,
body.midnight .weekly-section,
body.midnight .card-section {
  background: transparent;
  border-color: transparent;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

body.midnight .hero-detail,
body.midnight .hourly-item,
body.midnight .weekly-vcard {
  background: transparent;
  border-color: transparent;
}

body.midnight .hero-divider {
  background: transparent;
}

body.midnight .wvc-prob,
body.midnight .hourly-precip,
body.midnight .umb-need,
body.midnight .umb-maybe {
  color: rgba(255,255,255,0.08);
}

body.rainy {
  background: linear-gradient(160deg, #1a237e 0%, #37474F 100%);
}

a { color: inherit; }

/* ===== Screen Layout ===== */
.screen {
  min-height: 100vh;
}

.hidden {
  display: none !important;
}

/* ===== Loading ===== */
#loading-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}

.loading-anim {
  text-align: center;
}

.loading-icon {
  font-size: 72px;
  animation: float 2s ease-in-out infinite;
  display: block;
}

@keyframes float {
  0%, 100% { transform: translateY(0) rotate(-5deg); }
  50% { transform: translateY(-16px) rotate(5deg); }
}

.loading-anim p {
  margin-top: 20px;
  font-size: 18px;
  opacity: 0.75;
  letter-spacing: 0.05em;
}

/* ===== Main Content ===== */
.app-content {
  padding-top: 10px;
  padding-bottom: 24px;
}

/* ===== Hero ===== */
.hero-section {
  padding: 10px 10px 4px;
}

.hero-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 20px;
  padding: 14px 12px;
}

.hero-left {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.hero-icon {
  font-size: 52px;
  line-height: 1;
  filter: drop-shadow(0 2px 10px rgba(0,0,0,0.25));
}

.hero-center { text-align: left; }

.hero-temp {
  font-size: 48px;
  font-weight: 200;
  line-height: 1;
  letter-spacing: -1px;
}

.hero-desc {
  font-size: 15px;
  font-weight: 500;
  margin-top: 2px;
}

/* hero-time は .hero-clock として上段に表示（top-row内） */
.hero-clock {
  text-align: center;
  font-size: 102px;
  font-weight: 200;
  letter-spacing: 0.05em;
  flex-shrink: 0;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255,255,255,0.18);
}

/* hero-body: 時計の下の左右レイアウト */
.hero-body {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-height: 0;
}

.hero-high-low {
  font-size: 11px;
  opacity: 0.6;
  margin-top: 3px;
}

.hero-divider {
  width: 1px;
  align-self: stretch;
  background: rgba(255,255,255,0.2);
  flex-shrink: 0;
}

.hero-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.hero-detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.1);
  border-radius: 10px;
  padding: 5px 10px;
  flex: 1;
  gap: 6px;
}

.hd-label {
  font-size: 13px;
  opacity: 0.65;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}

.hd-value {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
}

.updated-at {
  font-size: 10px;
  opacity: 0.4;
  margin-top: 6px;
  text-align: center;
}

/* ===== Card Sections ===== */
.card-section {
  margin: 10px 10px 0;
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 16px;
  border: 1px solid rgba(255,255,255,0.12);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-header h2 {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.75;
}

.section-badge {
  font-size: 11px;
  background: rgba(255,255,255,0.18);
  padding: 2px 9px;
  border-radius: 20px;
  opacity: 0.8;
}

/* ===== Hourly Forecast ===== */
.hourly-list {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.hourly-list::-webkit-scrollbar { display: none; }

.hourly-item {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 14px;
  padding: 6px 5px;
  min-width: 58px;
}

.hourly-item.now {
  background: rgba(255,255,255,0.22);
  border-color: rgba(255,255,255,0.3);
}

.hourly-time { font-size: 13px; opacity: 0.65; margin-bottom: 4px; }
.hourly-icon { font-size: 24px; margin-bottom: 4px; }
.hourly-temp { font-size: 17px; font-weight: 600; margin-bottom: 2px; }
.hourly-precip { font-size: 13px; color: #90CAF9; min-height: 16px; transition: color 1.2s ease; }

/* ===== Precip Chart ===== */
.precip-canvas {
  width: 100%;
  display: block;
}

/* ===== Top Row ===== */
.top-row {
  display: flex;
  gap: 8px;
  padding: 10px 10px 0;
  align-items: stretch;
}

.top-row .hero-section {
  flex: 65;
  min-width: 0;
  padding: 0;
}

/* top-row内: hero-boxをcolumn（時計上・本体下）に */
.top-row .hero-box {
  flex-direction: column;
  gap: 0;
  height: 100%;
}

/* hero-body内のdividerは縦線のまま */
.top-row .hero-divider {
  width: 1px;
  height: auto;
  align-self: stretch;
}

.top-row .hero-details { flex: 1; align-self: stretch; }
.top-row .hero-left    { flex-shrink: 0; }

/* ===== Umbrella Forecast Column ===== */
.hero-umbrella {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex-shrink: 0;
}

.top-row .hero-umbrella {
  align-self: stretch;
}

/* 傘アイコンの色分け */
.umb-need  { color: #90CAF9; }                       /* ≥60% : ☂️ 青 */
.umb-maybe { color: rgba(144, 202, 249, 0.55); }     /* 30-59%: 🌂 薄青 */
.umb-clear { opacity: 0.28; }                        /* <30% : —  淡い */

.top-row .hero-clock    { font-size: 56px; }
.hero-clock .clock-date { display: block; font-size: 22px; font-weight: 700; opacity: 0.65; margin-bottom: 2px; }
.top-row .hero-icon     { font-size: 68px; }
.top-row .hero-temp     { font-size: 64px; letter-spacing: -2px; }
.top-row .hero-desc     { font-size: 24px; margin-top: 2px; }
.top-row .hero-high-low { font-size: 20px; margin-top: 4px; }
.top-row .hd-label      { font-size: 13px; }
.top-row .hd-value      { font-size: 15px; }
.top-row .hero-body     { margin-top: 8px; }

/* ===== Weekly Section (right of hero) ===== */
.weekly-section {
  flex: 35;
  min-width: 0;
  background: rgba(255,255,255,0.1);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 20px;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
}

.weekly-section .section-header {
  margin-bottom: 8px;
  flex-shrink: 0;
}

/* ===== Weekly Forecast Cards (hourly-style) ===== */
.weekly-vlist {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.weekly-vcard {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 4px 8px;
  min-height: 0;
}

.weekly-vcard.today {
  background: rgba(255,255,255,0.2);
  border-color: rgba(255,255,255,0.25);
}

.wvc-day  { font-size: 13px; font-weight: 600; width: 58px; flex-shrink: 0; white-space: nowrap; }
.wvc-icon { font-size: 20px; flex-shrink: 0; }
.wvc-max  { font-size: 14px; font-weight: 600; }
.wvc-min  { font-size: 13px; opacity: 0.5; margin-left: 2px; }
.wvc-prob { font-size: 12px; color: #90CAF9; margin-left: auto; flex-shrink: 0; transition: color 1.2s ease; }

/* ===== Radar ===== */
.toggle-btn {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: 20px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}

.toggle-btn.active { background: rgba(255,255,255,0.32); }
.toggle-btn:disabled { opacity: 0.5; }

.radar-section { margin-top: 4px; }

.radar-map {
  height: 270px;
  border-radius: 14px;
  overflow: hidden;
  background: rgba(0,0,0,0.3);
}

.radar-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 0 6px;
}

.radar-btn {
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  color: #fff;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
}

.radar-btn-play { min-width: 90px; }

.radar-timestamp {
  text-align: center;
  font-size: 12px;
  opacity: 0.65;
  padding-bottom: 4px;
}

/* ===== Error Screen ===== */
#error-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  padding: 32px 24px;
  text-align: center;
}

.error-content { max-width: 380px; }
.error-icon { font-size: 64px; margin-bottom: 16px; }
#error-title { font-size: 22px; margin-bottom: 10px; }
#error-message { opacity: 0.8; line-height: 1.6; margin-bottom: 24px; font-size: 15px; }

.retry-btn {
  display: block;
  width: 100%;
  background: rgba(255,255,255,0.2);
  border: 1px solid rgba(255,255,255,0.35);
  color: #fff;
  border-radius: 14px;
  padding: 14px;
  font-size: 16px;
  cursor: pointer;
  transition: background 0.15s;
}

.retry-btn:active { background: rgba(255,255,255,0.35); }

.loc-entry-btn {
  display: block;
  width: 100%;
  margin-top: 12px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  color: rgba(255,255,255,0.8);
  border-radius: 14px;
  padding: 13px;
  font-size: 15px;
  cursor: pointer;
  transition: background 0.15s;
}

.loc-entry-btn:active { background: rgba(255,255,255,0.15); }

/* ===== Location Screen ===== */
#location-screen {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px 24px;
  min-height: 100vh;
}

.loc-content {
  width: 100%;
  max-width: 440px;
}

.loc-header {
  text-align: center;
  margin-bottom: 20px;
}

.loc-header-icon {
  font-size: 48px;
  margin-bottom: 10px;
}

.loc-header h2 {
  font-size: 22px;
  font-weight: 600;
  margin-bottom: 0;
}

.loc-header p {
  font-size: 14px;
  opacity: 0.65;
}

.loc-gps-btn {
  display: block;
  width: 100%;
  background: rgba(255,255,255,0.18);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 14px;
  color: #fff;
  font-size: 16px;
  padding: 14px;
  cursor: pointer;
  margin-bottom: 20px;
  transition: background 0.15s;
}

.loc-gps-btn:active { background: rgba(255,255,255,0.32); }
.loc-gps-btn:disabled { opacity: 0.5; }

.loc-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.loc-divider::before,
.loc-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.2);
}

.loc-divider span {
  font-size: 12px;
  opacity: 0.5;
  white-space: nowrap;
}

.loc-manual-note {
  font-size: 13px;
  opacity: 0.6;
  text-align: center;
  margin-bottom: 14px;
}

.loc-form {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.loc-input {
  flex: 1;
  min-width: 0;
  background: rgba(255,255,255,0.15);
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 12px;
  color: #fff;
  font-size: 16px;
  padding: 12px 14px;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
}

.loc-input::placeholder { color: rgba(255,255,255,0.4); }
.loc-input:focus { border-color: rgba(255,255,255,0.6); background: rgba(255,255,255,0.2); }

.loc-search-btn {
  flex-shrink: 0;
  background: rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.35);
  border-radius: 12px;
  color: #fff;
  font-size: 15px;
  padding: 12px 16px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.loc-search-btn:active { background: rgba(255,255,255,0.4); }
.loc-search-btn:disabled { opacity: 0.5; }

.loc-status {
  font-size: 13px;
  opacity: 0.6;
  text-align: center;
  min-height: 20px;
  margin-bottom: 10px;
}

.loc-results {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 20px;
}

.loc-result-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  color: #fff;
  text-align: left;
  transition: background 0.15s;
}

.loc-result-item:active { background: rgba(255,255,255,0.25); }

.loc-result-name {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 2px;
}

.loc-result-display {
  font-size: 12px;
  opacity: 0.55;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  width: 100%;
}

.loc-back-btn {
  display: block;
  width: 100%;
  background: transparent;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 14px;
  padding: 10px;
  cursor: pointer;
  text-align: center;
}

.loc-back-btn:active { color: rgba(255,255,255,0.8); }

/* ===== Hero Meta (location + updated-at) ===== */
.hero-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
  padding: 0 2px;
}

.hero-location {
  font-size: 12px;
  opacity: 0.55;
  cursor: pointer;
  -webkit-tap-highlight-color: rgba(255,255,255,0.1);
}

.hero-location:active { opacity: 0.85; }

.hero-meta .updated-at {
  margin-top: 0;
  text-align: right;
}

/* ===== Footer ===== */
.app-footer {
  text-align: center;
  padding: 20px 16px 8px;
  line-height: 1.8;
}

.app-footer-copy {
  font-size: 11px;
  opacity: 0.4;
}

#footer-msg {
  position: relative;
  height: 1.6em;
  margin-bottom: 6px;
}

.msg-slot {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  font-size: 19px;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.msg-slot.visible {
  opacity: 0.75;
}

body.midnight .msg-slot {
  opacity: 0 !important;
}

/* ===== Landscape layout =====
   グリッド2カラムは横はみ出しの原因になるため使わない。
   ヒーローをコンパクトにして縦スクロールで使う。 */
@media (orientation: landscape) {
  .hero-icon  { font-size: 40px; }
  .hero-temp  { font-size: 38px; }
  .hero-desc  { font-size: 13px; }
  .hero-time  { font-size: 20px; }
  .hero-high-low { font-size: 10px; }

  .card-section { margin: 8px 10px 0; }
  .radar-map    { height: 200px; }
  .hourly-item  { min-width: 50px; padding: 7px 4px; }
  .hourly-icon  { font-size: 17px; }
}

/* ===== Leaflet overrides ===== */
.leaflet-control-attribution {
  font-size: 9px !important;
  background: rgba(0,0,0,0.4) !important;
  color: rgba(255,255,255,0.7) !important;
}

.leaflet-control-attribution a { color: rgba(255,255,255,0.7) !important; }
