/* ============================================
   EMILAI Contact Terminal - Styles
   ============================================ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --term-green: #1a8a3f;
  --term-cyan: #1E5A9F;
  --term-yellow: #b8860b;
  --term-red: #cc3333;
  --term-white: #333;
  --term-dim: #999;
  --term-bg: #ffffff;
  --term-glow: none;
}

body {
  background: #e8e6e3;
  color: var(--term-green);
  font-family: 'JetBrains Mono', 'Menlo', 'Courier New', monospace;
  font-size: 14px;
  line-height: 1.7;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* macOS window chrome — 3:2 aspect ratio */
#window {
  width: min(720px, calc(100vw - 32px));
  aspect-ratio: 3 / 2;
  max-height: calc(100vh - 48px);
  max-height: calc(100dvh - 48px);
  background: var(--term-bg);
  border-radius: 10px;
  box-shadow:
    0 22px 70px rgba(0, 0, 0, 0.15),
    0 0 0 0.5px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#titlebar {
  height: 38px;
  min-height: 38px;
  background: linear-gradient(180deg, #f6f6f6 0%, #e8e8e8 100%);
  border-bottom: 1px solid #d1d1d1;
  border-radius: 10px 10px 0 0;
  display: flex;
  align-items: center;
  padding: 0 14px;
  position: relative;
  -webkit-user-select: none;
  user-select: none;
}

.traffic-lights {
  display: flex;
  gap: 8px;
  z-index: 1;
}

.traffic-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 0.5px solid rgba(0, 0, 0, 0.12);
}

.tl-red { background: #ff5f57; }
.tl-yellow { background: #febc2e; }
.tl-green { background: #28c840; }

#titlebar-text {
  position: absolute;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 13px;
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  color: #4d4d4d;
  pointer-events: none;
}

#statusbar {
  height: 24px;
  min-height: 24px;
  background: linear-gradient(180deg, #e8e8e8 0%, #dcdcdc 100%);
  border-top: 1px solid #c8c8c8;
  border-radius: 0 0 10px 10px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  font-size: 11px;
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  color: #666;
  gap: 0;
  -webkit-user-select: none;
  user-select: none;
}

.status-item {
  padding: 0 10px;
  white-space: nowrap;
}

.status-item + .status-item {
  border-left: 1px solid #bbb;
}

.status-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #28c840;
  margin-right: 5px;
  vertical-align: middle;
}

#terminal {
  flex: 1;
  padding: 20px 24px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #ccc transparent;
}

#terminal::-webkit-scrollbar { width: 6px; }
#terminal::-webkit-scrollbar-track { background: transparent; }
#terminal::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

#output {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Input line */
#input-line {
  display: flex;
  align-items: center;
  margin-top: 4px;
  min-height: 28px;
}

#input-line.hidden { visibility: hidden; height: 0; min-height: 0; margin: 0; overflow: hidden; }

#prompt {
  color: var(--term-green);
  margin-right: 8px;
  flex-shrink: 0;
  font-weight: 700;
}

#user-input {
  background: transparent;
  border: none;
  color: var(--term-green);
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
  outline: none;
  width: 1ch;
  min-width: 1ch;
  max-width: 20ch;
  caret-color: transparent;
}

.cursor {
  display: inline-block;
  width: 9px;
  height: 17px;
  background: var(--term-green);
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
  flex-shrink: 0;
}

@keyframes blink { 50% { opacity: 0; } }

/* Line styles */
.line { min-height: 1.7em; }
.g { color: var(--term-green); }
.w { color: var(--term-white); }
.c { color: var(--term-cyan); }
.y { color: var(--term-yellow); }
.r { color: var(--term-red); }
.d { color: var(--term-dim); text-shadow: none; }
.b { font-weight: 700; }

.email-link {
  color: var(--term-cyan);
  text-decoration: underline;
  cursor: pointer;
}
.email-link:hover { color: #0d3d6e; }

/* Flicker on boot */
@keyframes flicker {
  0%, 100% { opacity: 1; }
  3% { opacity: 0.4; }
  6% { opacity: 1; }
  7% { opacity: 0.6; }
  9% { opacity: 1; }
}
.flicker { animation: flicker 0.3s linear; }

/* Mobile */
@media (max-width: 600px) {
  body { font-size: 12px; }
  #window {
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
  }
  #titlebar { border-radius: 0; }
  #statusbar { border-radius: 0; }
  #terminal { padding: 14px 16px; }
  /* iOS Safari auto-zoom 防止 — input は 16px 以上が必須（body の 12px 継承だと
     フォーカス時にページが拡大され、ターミナル UI が崩壊する） */
  #user-input { font-size: 16px; }
}
@media (max-width: 380px) {
  body { font-size: 11px; }
  #terminal { padding: 12px; }
  #user-input { font-size: 16px; }
}
