/* ==========================================================================
   作業計測タイマー スタイルシート
   ========================================================================== */

:root {
  --bg-color: #000000;
  --text-color: #ffffff;
  --btn-bg: #ffffff;
  --btn-text: #000000;
  --btn-border: #ffffff;
  --btn-active-red: #d00000;
  --overlay-break: rgba(20, 60, 190, 0.40);
  --modal-bg: #111111;
  --modal-border: #333333;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  background-color: var(--bg-color);
  color: var(--text-color);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

/* --------------------------------------------------------------------------
   青色オーバーレイ（休憩による自動停止中）
   -------------------------------------------------------------------------- */
.break-overlay {
  position: fixed;
  inset: 0;
  background-color: var(--overlay-break);
  pointer-events: none;
  z-index: 50;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.hidden {
  display: none !important;
}

/* --------------------------------------------------------------------------
   リセット確認ダイアログ
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-card {
  background-color: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 2px;
  padding: 20px;
  max-width: 280px;
  width: 100%;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.9);
}

.modal-title {
  font-size: 1.05rem;
  font-weight: bold;
  margin-bottom: 6px;
  color: #ffffff;
}

.modal-desc {
  font-size: 0.85rem;
  color: #cccccc;
  margin-bottom: 18px;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-dialog {
  flex: 1;
  padding: 8px 0;
  font-size: 0.95rem;
}

.btn-dialog-danger {
  background-color: var(--btn-active-red);
  color: #ffffff;
  border-color: var(--btn-active-red);
}

/* --------------------------------------------------------------------------
   共通ボタンスタイル
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--btn-bg);
  color: var(--btn-text);
  border: 1px solid var(--btn-border);
  border-radius: 1px;
  font-size: clamp(13px, 3vw, 15px);
  font-weight: 500;
  cursor: pointer;
  padding: 3px 12px;
  min-height: 32px;
  min-width: 72px;
  text-align: center;
  outline: none;
  touch-action: manipulation;
  transition: filter 0.08s;
}

.btn:active {
  filter: brightness(0.8);
}

/* 一時停止ボタン（アクティブ / 停止中） */
.btn-pause.is-active {
  background-color: var(--btn-active-red) !important;
  color: #000000 !important;
  border-color: var(--btn-active-red) !important;
  font-weight: bold;
}

/* 休憩ボタン（アクティブ / ON中） */
.btn-break.is-active {
  background-color: var(--btn-active-red) !important;
  color: #000000 !important;
  border-color: var(--btn-active-red) !important;
  font-weight: bold;
}

/* 開始ボタン */
.btn-start {
  min-width: 110px;
  min-height: 44px;
  font-size: clamp(1.3rem, 5.5vw, 1.6rem);
  padding: 6px 28px;
}

/* ボタンラッパー */
.btn-wrap {
  margin: 6px 0;
}

.top-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
}

/* --------------------------------------------------------------------------
   テキストスタイル
   -------------------------------------------------------------------------- */
.stat-line {
  font-size: clamp(11.5px, 2.9vw, 14px);
  line-height: 1.45;
  white-space: nowrap;
}

.current-time-line {
  font-size: clamp(11.5px, 2.9vw, 14px);
  line-height: 1.45;
  margin-top: 6px;
  text-align: right;
  white-space: nowrap;
}

.recent-title {
  font-size: clamp(11.5px, 2.9vw, 14px);
  margin-bottom: 2px;
  text-align: right;
}

.recent-times-list {
  list-style: none;
  font-size: clamp(11.5px, 2.9vw, 14px);
  line-height: 1.45;
  text-align: right;
}

.hourly-counts-container {
  display: flex;
  flex-direction: column;
}

/* --------------------------------------------------------------------------
   コンテナとレイアウト共通
   -------------------------------------------------------------------------- */
.app-container {
  width: 100%;
  height: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(12px, env(safe-area-inset-top))
           max(12px, env(safe-area-inset-right))
           max(12px, env(safe-area-inset-bottom))
           max(12px, env(safe-area-inset-left));
  cursor: pointer;
  position: relative;
}

.app-grid {
  width: 100%;
  height: 100%;
}

.grid-area {
  z-index: 5;
}

/* --------------------------------------------------------------------------
   縦向きレイアウト（Portrait）
   -------------------------------------------------------------------------- */
body.layout-portrait .app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    "stats   actions"
    "timer   timer"
    "elapsed recent";
  height: 100%;
  width: 100%;
}

body.layout-portrait .area-stats {
  grid-area: stats;
  align-self: start;
  justify-self: start;
}

body.layout-portrait .area-actions {
  grid-area: actions;
  align-self: start;
  justify-self: end;
  text-align: right;
}

body.layout-portrait .area-timer {
  grid-area: timer;
  align-self: center;
  justify-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  pointer-events: none;
}

body.layout-portrait .area-timer > * {
  pointer-events: auto;
}

body.layout-portrait .main-timer {
  font-size: clamp(4.2rem, 19vw, 6.8rem);
  font-weight: 400;
  letter-spacing: 2px;
  line-height: 1;
  text-align: center;
}

body.layout-portrait .start-btn-wrap {
  margin-top: 14px;
}

body.layout-portrait .area-elapsed {
  grid-area: elapsed;
  align-self: end;
  justify-self: start;
}

body.layout-portrait .area-recent {
  grid-area: recent;
  align-self: end;
  justify-self: end;
  text-align: right;
}

/* --------------------------------------------------------------------------
   横向きレイアウト（Landscape）
   -------------------------------------------------------------------------- */
body.layout-landscape .app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(auto, 1.35fr) minmax(0, 1fr);
  grid-template-rows: 1fr 1fr;
  grid-template-areas:
    "stats   timer actions"
    "elapsed timer recent";
  height: 100%;
  width: 100%;
  column-gap: 16px;
  row-gap: 4px;
  align-items: center;
}

body.layout-landscape .area-stats {
  grid-area: stats;
  align-self: start;
  justify-self: start;
}

body.layout-landscape .area-elapsed {
  grid-area: elapsed;
  align-self: end;
  justify-self: start;
}

body.layout-landscape .area-timer {
  grid-area: timer;
  align-self: center;
  justify-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

body.layout-landscape .area-timer > * {
  pointer-events: auto;
}

body.layout-landscape .main-timer {
  font-size: clamp(3.2rem, 12vw, 5.5rem);
  font-weight: 400;
  letter-spacing: 2px;
  line-height: 1;
  text-align: center;
}

body.layout-landscape .start-btn-wrap {
  margin-top: 6px;
}

body.layout-landscape .area-actions {
  grid-area: actions;
  align-self: start;
  justify-self: end;
  text-align: right;
}

body.layout-landscape .area-recent {
  grid-area: recent;
  align-self: end;
  justify-self: end;
  text-align: right;
}

body.layout-landscape .stat-line,
body.layout-landscape .current-time-line,
body.layout-landscape .recent-title,
body.layout-landscape .recent-times-list {
  font-size: clamp(10.5px, 2vw, 13px);
  line-height: 1.35;
}

body.layout-landscape .btn {
  font-size: 0.9rem;
  min-height: 30px;
  min-width: 66px;
  padding: 2px 10px;
}
