@import url("styles/theme.css");
@import url("styles/flip-clock.css");
@import url("styles/interaction.css");
@import url("styles/controls.css");

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font-sans);
  background: #CCC5B5;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

.app {
  background: var(--bg);
  color: var(--text);
  height: 100%;
  display: flex;
  flex-direction: column;
  font-size: calc(15px * var(--text-scale));
  transition: background 0.3s ease, color 0.3s ease;
}

.num { font-family: var(--font-mono); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.up { color: var(--up); }
.down { color: var(--down); }
.muted { color: var(--text-2); }
.muted-2 { color: var(--text-3); }

/* App bar */
.appbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px 10px;
  background: var(--bg);
  border-bottom: 1px solid transparent;
  flex: 0 0 auto;
}
.appbar-title { font-size: calc(20px * var(--text-scale)); font-weight: 600; letter-spacing: -0.01em; }
.appbar-title .zh { font-family: var(--font-sans); font-weight: 500; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 10px; border: none; background: transparent;
  color: var(--text); display: grid; place-items: center; cursor: pointer;
  transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { background: var(--surface-sunk); }

/* Scroll area */
.scroll {
  flex: 1; overflow-y: auto; overscroll-behavior: contain;
  padding: 0 16px 20px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.scroll::-webkit-scrollbar { width: 4px; }
.scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }

/* Card — 2.5D depth (gradient surface + double layered shadow + inset highlight) */
.card {
  background: linear-gradient(155deg, var(--surface), var(--surface-2));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow:
    0 12px 24px -10px rgba(0, 0, 0, 0.28),
    0 3px 8px -3px rgba(0, 0, 0, 0.14),
    0 1px 0 rgba(255, 255, 255, 0.55) inset;
}
[data-theme="dark"] .card {
  box-shadow:
    0 12px 24px -8px rgba(0, 0, 0, 0.62),
    0 3px 8px -3px rgba(0, 0, 0, 0.45),
    0 1px 0 rgba(255, 255, 255, 0.06) inset;
}
.card-tight { padding: 12px 14px; }
.card-flush { padding: 0; overflow: hidden; }

/* Panel — 扁平區段(表單/工具/資訊用):無陰影無漸層,hairline 邊。
   卡片(.card)保留給 hero/導覽磚/結果強調;一般內容區用 .panel 貼近原生 App。 */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
}
.panel-flush { padding: 0; overflow: hidden; }

.section-label {
  font-size: calc(12px * var(--text-scale));
  color: var(--text-3);
  margin: 20px 2px 10px;
  font-weight: 600;
  display: flex; align-items: center; justify-content: space-between;
}
.section-label .link {
  font-weight: 500;
  color: var(--accent); cursor: pointer;
}

/* Bottom nav */
.bottom-nav {
  display: flex; justify-content: space-around;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 4px max(6px, env(safe-area-inset-bottom));
  flex: 0 0 auto;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 6px 4px 4px; background: none; border: none; cursor: pointer;
  color: var(--text-3); font-family: inherit;
  transition: color 0.15s;
  font-size: calc(11px * var(--text-scale)); font-weight: 500;
  position: relative;
}
.nav-item.active { color: var(--text); }
.nav-item .nav-ico {
  width: 28px; height: 28px; display: grid; place-items: center;
  border-radius: 12px;
  transition: background 0.2s;
}
.nav-item.active .nav-ico { background: var(--accent-soft); }
.nav-label { letter-spacing: 0.02em; }

/* Pill / chip */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 8px; border-radius: 999px;
  font-size: calc(11px * var(--text-scale)); font-weight: 600;
  background: var(--surface-2); color: var(--text-2);
}
.chip.up { background: var(--up-soft); color: var(--up); }
.chip.down { background: var(--down-soft); color: var(--down); }

/* Divider */
.hr { height: 1px; background: var(--border); margin: 0; border: 0; }

/* Row (list item) */
.row {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 14px;
  cursor: pointer;
  transition: background 0.12s;
}
.row:hover { background: var(--surface-2); }
.row + .row { border-top: 1px solid var(--border); }

/* Bottom sheet / drawer */
.scrim {
  position: absolute; inset: 0; background: rgba(20, 16, 10, 0.35);
  backdrop-filter: blur(2px);
  opacity: 0; pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 30;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: absolute; top: 0; left: 0; bottom: 0; width: 84%; max-width: 340px;
  background: var(--surface); z-index: 40;
  transform: translateX(-100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; flex-direction: column;
  border-right: 1px solid var(--border);
}
.drawer.open { transform: translateX(0); }
.drawer-header {
  padding: 20px 20px 16px; border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}
.drawer-title { font-size: calc(12px * var(--text-scale)); letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-3); font-weight: 600; }
.drawer-sub { font-size: calc(18px * var(--text-scale)); font-weight: 600; margin-top: 2px; }
.drawer-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.drawer-scroll::-webkit-scrollbar { width: 4px; }
.drawer-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 2px; }
.drawer-section { padding: 14px 8px 6px; }
.drawer-section h4 {
  font-size: calc(11px * var(--text-scale)); letter-spacing: 0.1em;
  color: var(--text-3); text-transform: uppercase;
  margin: 0 0 6px; padding: 0 12px; font-weight: 600;
}
.drawer-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px; border-radius: 10px;
  cursor: pointer; color: var(--text);
  font-size: calc(14px * var(--text-scale)); font-weight: 500;
  transition: background 0.12s;
}
.drawer-item:hover { background: var(--surface-2); }
.drawer-item.active { background: var(--accent-soft); color: var(--accent); }

/* Refresh indicator */
.refresh {
  display: flex; align-items: center; justify-content: center;
  padding: 8px; color: var(--text-3);
  font-size: calc(12px * var(--text-scale)); gap: 8px;
  height: 0; overflow: hidden;
  transition: height 0.2s;
}
.refresh.pulling { height: 40px; }
.refresh.refreshing { height: 40px; }
.spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid var(--border-strong);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Drag-reorder */
.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
  background: var(--accent-soft) !important;
}
.drag-active {
  z-index: 10;
  box-shadow: 0 8px 22px rgba(0,0,0,0.18);
}
