/* clock/styles.css — Neoncity Clock + Pomodoro Timer */

/* ── Variables ──────────────────────────────────────────────────────────────── */
:root {
  --bg:          #05080f;
  --bg-card:     rgba(255, 255, 255, 0.05);
  --border:      rgba(255, 255, 255, 0.10);
  --text:        #e9f3ff;
  --text-muted:  #97a7bf;

  --accent:      #27e6ff;
  --accent2:     #ff4bd1;
  --accent-glow: rgba(39, 230, 255, 0.35);

  --ring-bg:     rgba(255, 255, 255, 0.08);
  --ring-color:  var(--accent);
  --ring-paused: rgba(255, 75, 209, 0.7);

  --radius:      16px;
  --transition:  0.25s ease;
  --clock-corner-top: 72px;
  --clock-corner-right: 20px;
  --clock-corner-scale: 0.32;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  /* Prevent text selection on long-press (iPad) */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

/* ── System bar ──────────────────────────────────────────────────────────────── */
#system-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  z-index: 100;
  background: linear-gradient(to bottom, rgba(5,8,15,0.9), transparent);
  pointer-events: none; /* Let clicks through to app */
  transition: opacity var(--transition);
}

#system-bar > * { pointer-events: auto; }

/* Non-touch devices: fade out system-bar in fullscreen, restore on hover */
@media (hover: hover) {
  #system-bar.in-fullscreen { opacity: 0; }
  #system-bar.in-fullscreen:hover { opacity: 1; }
}

.back-link {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(255,255,255,0.04);
  transition: color var(--transition), border-color var(--transition);
}

.back-link:hover { color: var(--text); border-color: rgba(255,255,255,0.25); }

#status-icons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-icon {
  font-size: 1rem;
  opacity: 0.6;
}

.icon-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 1.15rem;
  padding: 6px 10px;
  cursor: pointer;
  transition: all var(--transition);
  line-height: 1;
}

.icon-btn:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text);
  border-color: rgba(255,255,255,0.3);
}

/* ── Main layout ─────────────────────────────────────────────────────────────── */
/* #app はリング専用コンテナ。他の要素はすべて position: fixed で独立配置 */
#app {
  position: fixed;
  inset: 0;
  pointer-events: none; /* ring は装飾のみ */
}

/* ── SVG Ring ────────────────────────────────────────────────────────────────── */
#ring-container {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

#ring-container.ring-active {
  opacity: 1;
  transform: scale(1);
}

#progress-ring {
  width: 85vmin;
  height: 85vmin;
  max-width: 640px;
  max-height: 640px;
}

#ring-bg {
  fill: none;
  stroke: var(--ring-bg);
  stroke-width: 6;
}

#ring-progress {
  fill: none;
  stroke: var(--ring-color);
  stroke-width: 5;
  stroke-linecap: round;
  /* Rotate to start at top */
  transform: rotate(-90deg);
  transform-origin: 200px 200px;
  transition: stroke-dashoffset 0.6s linear, stroke var(--transition);
  filter: drop-shadow(0 0 8px var(--accent-glow));
}

/* Paused state: dimmer ring */
body.timer-paused #ring-progress {
  stroke: var(--ring-paused);
  filter: drop-shadow(0 0 6px rgba(255,75,209,0.3));
  animation: pulse-ring 2s ease-in-out infinite;
}

@keyframes pulse-ring {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.45; }
}

/* ── Clock area ─────────────────────────────────────────────────────────────────
   Idle:  画面中央
   Active: 右上へ縮小移動（Safari互換のためCSSのみでレイアウト）
   ──────────────────────────────────────────────────────────────────────────── */
#clock-area {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  white-space: nowrap;

  /* Idle: viewport中央。timer-active時はCSSで右上へ遷移 */
  transform: translate(-50%, -50%);
  transform-origin: top right;

  transition: top    0.65s cubic-bezier(0.4, 0, 0.2, 1),
              left   0.65s cubic-bezier(0.4, 0, 0.2, 1),
              transform 0.65s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: top, left, transform;
}

body.timer-active #clock-area {
  top: var(--clock-corner-top);
  left: calc(100vw - var(--clock-corner-right));
  transform: translate(-100%, 0) scale(var(--clock-corner-scale));
}

@supports (top: calc(env(safe-area-inset-top) + 1px)) {
  body.timer-active #clock-area {
    top: calc(env(safe-area-inset-top) + var(--clock-corner-top));
    left: calc(100vw - env(safe-area-inset-right) - var(--clock-corner-right));
  }
}

/* Date: タイマー中は非表示（32%に縮んで読めないため） */
#date-display {
  transition: opacity 0.35s ease;
}
body.timer-active #date-display {
  opacity: 0;
}

#time-display {
  font-size: clamp(5rem, 18vw, 11rem);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1;
  color: var(--text);
  text-shadow: 0 0 40px rgba(255,255,255,0.12);
}

#time-sep {
  opacity: 0.4;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 0.4; }
  50%       { opacity: 0.05; }
}

#time-sec {
  font-size: 0.6em;
  opacity: 0.55;
  vertical-align: baseline;
  letter-spacing: 0;
}

#date-display {
  color: var(--text-muted);
  font-size: clamp(0.8rem, 2.2vw, 1.1rem);
  letter-spacing: 0.04em;
  font-weight: 400;
}

/* ── Timer display（画面中央固定、タイマー動作中のみ表示） ─────────────────── */
#timer-display {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

#timer-display.timer-visible {
  animation: fade-in-up 0.4s ease both;
}

@keyframes fade-in-up {
  from { opacity: 0; transform: translate(-50%, calc(-50% + 10px)); }
  to   { opacity: 1; transform: translate(-50%, -50%); }
}

#timer-remaining {
  font-size: clamp(3rem, 9vw, 5.5rem);
  font-weight: 300;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
  text-shadow: 0 0 30px var(--accent-glow);
  letter-spacing: 0.02em;
  line-height: 1;
}

#timer-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* ── Controls（画面下部中央固定） ───────────────────────────────────────────── */
#controls {
  position: fixed;
  bottom: 40px;
  bottom: max(40px, calc(env(safe-area-inset-bottom) + 32px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  pointer-events: auto;
}

/* Preset buttons */
#preset-btns {
  display: flex;
  gap: 20px;
}

.preset-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: clamp(90px, 22vw, 140px);
  height: clamp(90px, 22vw, 140px);
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(8px);
  position: relative;
  overflow: hidden;
}

.preset-btn::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: 50%;
  background: conic-gradient(var(--accent), var(--accent2), var(--accent));
  opacity: 0;
  transition: opacity var(--transition);
  z-index: -1;
}

.preset-btn:hover { transform: scale(1.06); }
.preset-btn:hover::before { opacity: 1; }
.preset-btn:active { transform: scale(0.97); }

.preset-min {
  font-size: clamp(1.8rem, 5vw, 2.8rem);
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}

.preset-unit {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}

/* Control buttons */
#timer-btns, #paused-btns {
  display: flex;
  gap: 12px;
}

.ctrl-btn {
  padding: 14px 28px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  backdrop-filter: blur(8px);
  letter-spacing: 0.02em;
  min-width: 120px;
}

.ctrl-btn:hover {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.25);
}

.ctrl-btn:active { transform: scale(0.97); }

.ctrl-btn--ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}

.ctrl-btn--ghost:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--border);
  color: var(--text);
}

/* Finished */
#finished-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#finished-text {
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: 700;
  color: var(--accent);
  text-shadow: 0 0 24px var(--accent-glow);
  animation: finished-pulse 1s ease-in-out infinite;
}

@keyframes finished-pulse {
  0%, 100% { text-shadow: 0 0 24px var(--accent-glow); }
  50%       { text-shadow: 0 0 48px var(--accent-glow), 0 0 80px var(--accent-glow); }
}

/* ── Flash animation (on finish) ─────────────────────────────────────────────── */
body.flash::after {
  content: '';
  position: fixed;
  inset: 0;
  border: 4px solid var(--accent);
  box-shadow: inset 0 0 80px var(--accent-glow), 0 0 80px var(--accent-glow);
  animation: flash-anim 1.5s ease forwards;
  pointer-events: none;
  z-index: 9999;
}

@keyframes flash-anim {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* ── iOS Hint banner ─────────────────────────────────────────────────────────── */
#ios-hint {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(12, 18, 32, 0.92);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  font-size: 0.875rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 14px;
  backdrop-filter: blur(12px);
  z-index: 200;
  max-width: 90vw;
  white-space: nowrap;
}

#ios-hint-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  padding: 0 4px;
  flex-shrink: 0;
}

/* ── Utility ─────────────────────────────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Fullscreen overrides ────────────────────────────────────────────────────── */
:fullscreen body,
:-webkit-full-screen body {
  background: var(--bg);
}

/* ── Landscape (iPad in landscape mode) ─────────────────────────────────────── */
@media (orientation: landscape) and (max-height: 600px) {
  #time-display { font-size: clamp(3.5rem, 12vh, 7rem); }
  #timer-remaining { font-size: clamp(1.5rem, 5vh, 3rem); }

  #clock-area { gap: 4px; }
  #controls { margin-top: 20px; }

  .preset-btn {
    width: clamp(72px, 14vh, 110px);
    height: clamp(72px, 14vh, 110px);
  }

  .preset-min { font-size: clamp(1.4rem, 4vh, 2.2rem); }
}

/* Safe area for notch/home indicator (iPad) */
#system-bar {
  padding-top: 14px;
  padding-top: max(14px, env(safe-area-inset-top));
  padding-left: 20px;
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: 20px;
  padding-right: max(20px, env(safe-area-inset-right));
}

#controls {
  padding-bottom: 20px;
  padding-bottom: max(20px, env(safe-area-inset-bottom));
}
