/* 集中タイマー — Day 001
   外部フォント・外部CSSは一切読み込まない（file:// で単体動作させるため） */

:root {
  --bg: #14161c;
  --panel: #1d212b;
  --panel-2: #262b38;
  --text: #eef1f6;
  --muted: #9aa3b2;
  --accent: #4f9cff;
  --accent-strong: #2f7ff0;
  --done-bg: #1f4d33;
  --done-accent: #4ade80;
  --danger: #ff8a8a;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans",
               "Yu Gothic", "Noto Sans JP", "Segoe UI", sans-serif;
  line-height: 1.6;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px 48px;
  transition: background-color .4s ease;
}

/* 終了時の視覚的な合図：背景色が変わる＋数字が点滅する */
body[data-state="finished"] {
  background: var(--done-bg);
}

.app {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.app__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--muted);
  text-align: center;
}

/* ---- 残り時間の表示 ---- */
.display {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 28px 16px 20px;
  text-align: center;
}

.display__time {
  margin: 0;
  font-size: clamp(3.75rem, 22vw, 6.5rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: .02em;
  font-variant-numeric: tabular-nums;
  font-family: "SF Mono", "Menlo", "Consolas", ui-monospace, monospace;
}

body[data-state="paused"] .display__time { color: var(--muted); }

body[data-state="finished"] .display__time {
  color: var(--done-accent);
  animation: blink 1s ease-in-out infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: .35; }
}

@media (prefers-reduced-motion: reduce) {
  body[data-state="finished"] .display__time { animation: none; }
}

.display__status {
  margin: 8px 0 0;
  font-size: .9rem;
  color: var(--muted);
  min-height: 1.6em;
}

body[data-state="finished"] .display__status { color: var(--done-accent); }

/* ---- 時間セット ---- */
.setter {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
}

.setter__label {
  margin: 0 0 12px;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--muted);
}

.presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.custom {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}

.custom__label {
  font-size: .8rem;
  color: var(--muted);
  white-space: nowrap;
}

.custom__input {
  flex: 1 1 auto;
  min-width: 0;
  background: var(--panel-2);
  border: 1px solid #39404f;
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  padding: 10px 12px;
  text-align: right;
}

.custom__input:focus-visible,
.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.custom__input:disabled { opacity: .45; }

.custom__error {
  margin: 10px 0 0;
  font-size: .8rem;
  color: var(--danger);
}

/* ---- 操作ボタン ---- */
.controls {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 8px;
}

.btn {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid transparent;
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  padding: 14px 8px;
  min-height: 48px;
  cursor: pointer;
  transition: background-color .15s ease, opacity .15s ease;
}

.btn:hover:not(:disabled) { background: #323847; }

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

.btn--preset {
  font-size: .95rem;
  padding: 12px 4px;
}

.btn--preset.is-selected {
  background: var(--accent-strong);
  border-color: var(--accent);
}

.btn--preset.is-selected:hover:not(:disabled) { background: var(--accent); }

.btn--primary {
  background: var(--accent-strong);
}

.btn--primary:hover:not(:disabled) { background: var(--accent); }

.btn--ghost {
  background: transparent;
  border-color: #39404f;
  font-size: .9rem;
  padding: 10px 14px;
  min-height: 44px;
  flex: 0 0 auto;
}

.hint {
  margin: 0;
  text-align: center;
  font-size: .75rem;
  color: var(--muted);
}

/* スマホでは操作ボタンを縦に並べず、押しやすい高さだけ確保する */
@media (max-width: 380px) {
  .controls { grid-template-columns: 1fr 1fr; }
  .controls .btn--primary { grid-column: 1 / -1; }
  .presets { grid-template-columns: repeat(2, 1fr); }
}

/* マウス操作でないデバイス向けにhoverの残留を防ぐ */
@media (hover: none) {
  .btn:hover:not(:disabled) { background: var(--panel-2); }
  .btn--primary:hover:not(:disabled),
  .btn--preset.is-selected:hover:not(:disabled) { background: var(--accent-strong); }
}
