/* =========================================
   高級感テーマ変数（ライトモード）
========================================= */
:root {
  --bg: #eef2f7;
  --card-bg: rgba(255, 255, 255, 0.55);
  --card-border: rgba(255, 255, 255, 0.35);
  --primary: #1f2933;
  --accent: #3b82f6;
  --second-color: #ff7e5f;
  --text-main: #111827;
  --text-sub: #6b7280;

  --glass-bg: rgba(255, 255, 255, 0.25);
  --glass-border: rgba(255, 255, 255, 0.45);

  --radius: 24px;

  --shadow-soft: 0 10px 30px rgba(0,0,0,0.08);
  --shadow-inner: inset 2px 2px 6px rgba(255,255,255,0.6),
                  inset -2px -2px 6px rgba(0,0,0,0.05);
}

/* =========================================
   ダークモード（時計は従来の LED 風）
========================================= */
body.dark {
  --bg: #0f172a;
  --card-bg: rgba(20, 25, 40, 0.6);
  --card-border: rgba(255, 255, 255, 0.1);
  --text-main: #e5e7eb;
  --text-sub: #9ca3af;
  --shadow-soft: 0 10px 30px rgba(0,0,0,0.6);
  --glass-bg: rgba(20, 25, 40, 0.6);
  --glass-border: rgba(255, 255, 255, 0.08);
}

/* =========================================
   全体レイアウト
========================================= */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: "Inter", system-ui, sans-serif;
}

body {
  background: linear-gradient(135deg, #f8fafc, #e2e8f0);
  color: var(--text-main);
  min-height: 100vh;
  padding: 20px;
  transition: background 0.4s ease, color 0.4s ease;
}

body.dark {
  background: linear-gradient(135deg, #0f172a, #1e293b);
}

.app {
  max-width: 1500px;
  margin: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* =========================================
   Header（高級感）
========================================= */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-radius: var(--radius);
  background: var(--card-bg);
  backdrop-filter: blur(18px);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-soft);
  flex-wrap: wrap;
  gap: 12px;
}

.brand-title {
  font-weight: 700;
  letter-spacing: 0.05em;
  font-size: 1.2rem;
}

.brand-sub {
  font-size: 0.85rem;
  color: var(--text-sub);
}

nav {
  display: flex;
  gap: 10px;
  font-size: 0.85rem;
  color: var(--text-sub);
}

nav span {
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-inner);
}

/* テーマ切り替えボタン */
.theme-toggle {
  border: none;
  border-radius: 999px;
  padding: 8px 14px;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-inner);
  cursor: pointer;
}

/* =========================================
   Main：PCでは左右並び
========================================= */
main {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
}

@media (max-width: 900px) {
  main {
    grid-template-columns: 1fr;
  }
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  padding: 20px 22px;
  backdrop-filter: blur(18px);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-soft);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* =========================================
   時計：Glass Neumorphism（ライトモード）
========================================= */
.clock-glass {
  border-radius: 28px;
  padding: 20px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(22px) saturate(160%);
  box-shadow:
    0 20px 40px rgba(0,0,0,0.12),
    inset 2px 2px 6px rgba(255,255,255,0.6),
    inset -2px -2px 6px rgba(0,0,0,0.05);
}

/* ダークモード時は従来の LED 風 */
body.dark .clock-glass {
  background: #0a0f1f;
  border: 1px solid #1e293b;
  box-shadow:
    0 20px 40px rgba(0,0,0,0.6),
    inset 0 0 0 1px rgba(255,255,255,0.05);
}

/* =========================================
   フリップ時計（1枚パネル）
========================================= */
.flip-clock-wrapper {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.flip-row {
  display: flex;
  justify-content: center;
  gap: clamp(20px, 4vw, 60px);
}

.flip-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.flip-label {
  font-size: 0.8rem;
  color: var(--text-sub);
}

/* Glass Neumorphism パネル（ライトモード） */
.flip-card {
  position: relative;
  width: clamp(120px, 14vw, 220px);
  height: clamp(160px, 18vw, 300px);
  perspective: 1400px;
  border-radius: 20px;
  overflow: hidden;
}

.flip-face {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  backface-visibility: hidden;
  transition: background 0.3s ease;
}

/* ライトモード：ガラス質感 */
body:not(.dark) .flip-face {
  background: rgba(255,255,255,0.35);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(255,255,255,0.45);
  box-shadow:
    inset 2px 2px 6px rgba(255,255,255,0.6),
    inset -2px -2px 6px rgba(0,0,0,0.05),
    0 10px 20px rgba(0,0,0,0.08);
}

/* ダークモード：従来の LED 風 */
body.dark .flip-face {
  background: radial-gradient(circle at top left, #050816, #020617);
  border: 1px solid rgba(255,255,255,0.05);
  box-shadow:
    0 14px 26px rgba(0,0,0,0.8),
    0 0 0 1px rgba(15,23,42,0.9);
}

.flip-number {
  font-family: 'Digital-7', monospace;
  font-size: clamp(4rem, 7vw, 7rem);
  font-weight: 800;
  letter-spacing: -0.03em;
}

/* 秒だけ色変更 */
.second-color {
  color: var(--second-color);
}

/* アニメーション */
.flip-current {
  transform: rotateX(0deg);
}

.flip-next {
  transform: rotateX(90deg) translateY(20%);
  opacity: 0;
  transform-origin: center bottom;
}

.flip-card.flip-animating .flip-current {
  animation: flipOut 0.35s ease-in forwards;
}

.flip-card.flip-animating .flip-next {
  animation: flipIn 0.35s ease-out 0.35s forwards;
}

@keyframes flipOut {
  0% { transform: rotateX(0deg); opacity: 1; }
  100% { transform: rotateX(-90deg); opacity: 0; }
}

@keyframes flipIn {
  0% { transform: rotateX(90deg); opacity: 0; }
  100% { transform: rotateX(0deg); opacity: 1; }
}

/* 秒の揺れ */
.flip-second {
  will-change: transform;
  transform: rotateX(var(--sec-tilt, 0deg));
}

/* 日付 */
.flip-meta {
  text-align: center;
  font-size: 1.1rem;
  color: var(--text-sub);
}

/* =========================================
   Google カレンダー風デザイン
========================================= */
.calendar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.calendar-month {
  font-weight: 600;
  font-size: 1.2rem;
}

.calendar-nav button {
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  background: #fff;
  border: 1px solid #d1d5db;
  cursor: pointer;
  transition: 0.2s;
}

.calendar-nav button:hover {
  background: #f3f4f6;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  background: #e5e7eb;
  padding: 6px;
  border-radius: 14px;
}

.calendar-cell {
  background: #fff;
  padding: 10px 0;
  text-align: center;
  border-radius: 10px;
  font-size: 0.9rem;
  border: 1px solid #e5e7eb;
}

.calendar-cell.header {
  background: #f3f4f6;
  font-weight: 600;
}

.calendar-cell.today {
  background: #3b82f6;
  color: #fff;
  font-weight: 700;
  border-radius: 50%;
}

.calendar-cell.holiday {
  color: #dc2626;
  font-weight: 600;
}

/* =========================================
   天気（WeatherAPI.com）＋検索＋週間予報
========================================= */
.weather {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.weather-location {
  font-size: 0.9rem;
  color: var(--text-sub);
}

/* 検索バー */
.weather-search {
  display: flex;
  gap: 10px;
}

.weather-search input {
  flex: 1;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  padding: 8px 14px;
  font-size: 0.9rem;
  background: rgba(255,255,255,0.7);
  backdrop-filter: blur(10px);
}

.weather-search button {
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  color: #fff;
  cursor: pointer;
  transition: 0.2s;
}

.weather-search button:hover {
  opacity: 0.85;
}

.weather-main {
  display: flex;
  gap: 16px;
  align-items: center;
}

.weather-temp {
  font-size: 2.4rem;
  font-weight: 600;
}

.weather-desc {
  font-size: 1rem;
  color: var(--text-sub);
}

.weather-meta {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  font-size: 0.85rem;
}

.weather-meta span {
  padding: 8px 10px;
  border-radius: 12px;
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-inner);
}

/* 天気アイコン（派手アニメーション） */
.weather-icon-wrapper {
  width: 100px;
  height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.weather-icon {
  width: 100px;
  height: 100px;
  animation:
    floatIcon 3s ease-in-out infinite,
    rotateIcon 12s linear infinite,
    pulseIcon 2.4s ease-in-out infinite;
}

/* 浮遊 */
@keyframes floatIcon {
  0%   { transform: translateY(0px); }
  50%  { transform: translateY(-12px); }
  100% { transform: translateY(0px); }
}

/* ゆっくり回転 */
@keyframes rotateIcon {
  0%   { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* 拡大縮小（脈動） */
@keyframes pulseIcon {
  0%   { filter: drop-shadow(0 0 4px rgba(255,255,255,0.4)); transform: scale(1); }
  50%  { filter: drop-shadow(0 0 14px rgba(255,255,255,0.9)); transform: scale(1.15); }
  100% { filter: drop-shadow(0 0 4px rgba(255,255,255,0.4)); transform: scale(1); }
}

/* 週間予報 */
.forecast {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.forecast-title {
  font-size: 0.9rem;
  color: var(--text-sub);
}

.forecast-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(95px, 1fr));
  gap: 10px;
}

.forecast-item {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 10px 6px;
  text-align: center;
  font-size: 0.8rem;
  border: 1px solid var(--card-border);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-soft);
}

.forecast-date {
  font-weight: 600;
  margin-bottom: 4px;
}

.forecast-icon {
  width: 42px;
  height: 42px;
}

.forecast-temp {
  margin-top: 4px;
  font-weight: 600;
}

/* =========================================
   メモ
========================================= */
.memo {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.memo textarea {
  width: 100%;
  min-height: 160px;
  border-radius: 18px;
  border: none;
  padding: 14px;
  resize: vertical;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-inner);
  color: var(--text-main);
}

.memo textarea:focus {
  outline: none;
}

.memo-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.85rem;
  color: var(--text-sub);
}

.memo-actions button {
  border: none;
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 0.85rem;
  background: linear-gradient(135deg, #3b82f6, #60a5fa);
  color: #fff;
  cursor: pointer;
}

/* =========================================
   Footer
========================================= */
footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-sub);
  margin-top: 10px;
  padding: 10px 0;
}

/* =========================================
   スマホ最適化
========================================= */
@media (max-width: 900px) {

  main {
    grid-template-columns: 1fr;
  }

  .flip-card {
    width: 110px;
    height: 150px;
  }

  .flip-number {
    font-size: 3.5rem;
  }

  .weather-icon {
    width: 80px;
    height: 80px;
  }

  .weather-main {
    flex-direction: row;
    gap: 12px;
  }

  .memo textarea {
    min-height: 130px;
  }

  .card {
    padding: 16px;
  }
}

/* =========================================
   スクロールバー（高級感デザイン）
========================================= */
::-webkit-scrollbar {
  width: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 10px;
  border: 2px solid var(--bg);
}

::-webkit-scrollbar-thumb:hover {
  background: #2563eb;
}

/* =========================================
   アニメーションの最適化
========================================= */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
}

/* =========================================
   印刷用（背景を白に）
========================================= */
@media print {
  body {
    background: #fff;
  }
  .card,
  .clock-glass,
  header,
  footer {
    box-shadow: none;
    background: #fff;
    border: 1px solid #ccc;
  }
  .weather-icon,
  .forecast-icon {
    animation: none !important;
  }
}
