/* css/effects.css - 台詞・エラーダイアログ（緊急パッチ）・グリッチ・走馬灯・ヘルプ */

/* ===================================================
   台詞（場面ウィンドウの下部に重ねるメッセージ窓）
   =================================================== */
#dialogue-overlay {
  position: relative;
  height: 100%;
  z-index: 50;
}

#dialogue-overlay[hidden] {
  display: none !important;
}

.dialogue-box {
  position: relative;
  height: 100%;
  min-height: 5.8rem;
  padding: 1.1rem 1.2rem 0.9rem;
  background: var(--field);
  box-shadow: inset 0 0 0 2px var(--face-dk), inset 0 0 0 4px var(--face), inset 0 0 0 5px var(--face-lo), 4px 4px 0 rgba(0, 0, 0, 0.35);
  cursor: pointer;
  touch-action: manipulation;
}

.dialogue-header {
  position: absolute;
  top: -0.85rem;
  left: 0.9rem;
  right: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  pointer-events: none;
}

.dialogue-speaker {
  padding: 0.1rem 0.65rem;
  background: linear-gradient(90deg, var(--title-a), var(--title-b));
  color: #fff;
  font-family: var(--font-pixel);
  font-size: 0.9rem;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.35);
}

.dialogue-hint {
  padding: 0 0.4rem;
  background: var(--balloon);
  color: var(--ink-muted);
  font-family: var(--font-pixel);
  font-size: 0.75rem;
  animation: pulse-hint 1.2s steps(2) infinite;
}

@keyframes pulse-hint {
  from { opacity: 0.45; }
  to { opacity: 1; }
}

.dialogue-message {
  font-size: 1.05rem;
  line-height: 1.75;
  color: var(--ink);
  min-height: 1.75em;
  word-break: break-all;
}

/* ===================================================
   緊急パッチ選択（OS のエラーダイアログ）
   =================================================== */
#patch-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(60, 0, 0, 0.25);
}

#patch-modal-overlay[hidden] {
  display: none !important;
}

.patch-card {
  width: min(560px, 100%);
  max-height: 92vh;
  max-height: 92dvh;
  overflow-y: auto;
  background: var(--face);
  box-shadow: var(--raised), var(--drop);
  padding: 3px;
  display: flex;
  flex-direction: column;
  animation: dialog-pop 0.12s steps(2);
}

@keyframes dialog-pop {
  from { transform: scale(0.96); }
  to { transform: scale(1); }
}

.patch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  min-height: 1.9rem;
  padding: 0.15rem 0.5rem;
  background: linear-gradient(90deg, #6b0d10, #c0392b);
  color: #fff;
  font-family: var(--font-pixel);
}

.patch-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.95rem;
  min-width: 0;
}

.patch-title > :first-child {
  color: #fff !important;
}

.patch-risk-badge {
  font-size: 0.75rem;
  padding: 0 0.35rem;
  background: rgba(255, 255, 255, 0.2);
  white-space: nowrap;
}

.patch-lead {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.9rem;
  align-items: start;
  padding: 1rem 1.1rem 0.4rem;
}

.patch-error-icon {
  width: 2.6rem;
  height: 2.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--danger);
  color: #fff;
  font-size: 1.4rem;
  font-weight: 700;
  box-shadow: 2px 2px 0 var(--face-dk);
}

.patch-lead-text {
  font-size: 0.92rem;
  line-height: 1.6;
}

.patch-guidance,
.patch-ram-hint {
  margin: 0.4rem 1.1rem 0;
  padding: 0.45rem 0.65rem;
  background: var(--balloon);
  box-shadow: inset 0 0 0 1px var(--face-lo);
  font-size: 0.84rem;
  line-height: 1.5;
  display: flex;
  gap: 0.4rem;
}

.patch-status-row {
  margin: 0.7rem 1.1rem 0;
  font-size: 0.9rem;
}

.patch-status-row strong {
  font-family: var(--font-pixel);
  font-size: 1.15rem;
  font-weight: 400;
}

.patch-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 0.75rem 1.1rem 1rem;
}

.patch-btn {
  min-height: 56px;
  border: none;
  background: var(--face);
  box-shadow: var(--raised);
  padding: 0.55rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-align: left;
  font-family: var(--font-sans);
  color: var(--ink);
  cursor: pointer;
  touch-action: manipulation;
}

.patch-btn:hover:not(.disabled) {
  background: var(--face-lt);
}

.patch-btn:active:not(.disabled) {
  box-shadow: var(--pressed);
}

.patch-btn-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.patch-btn-title {
  font-weight: 700;
  font-size: 0.98rem;
}

.patch-btn-cost {
  font-family: var(--font-pixel);
  font-size: 0.9rem;
  color: var(--accent);
}

.patch-btn-desc {
  font-size: 0.84rem;
  color: var(--ink-muted);
  line-height: 1.45;
}

.patch-btn.disabled {
  cursor: not-allowed;
  color: var(--face-lo);
}

.patch-btn.disabled .patch-btn-title,
.patch-btn.disabled .patch-btn-cost {
  color: var(--face-lo);
}

.patch-btn.disabled .patch-btn-desc {
  color: var(--danger);
}

.patch-btn-warn {
  font-size: 0.8rem;
  color: var(--warn);
  font-weight: 700;
}

/* ===================================================
   グリッチ（画面のゆれ: 3Hz 以下）
   =================================================== */
.glitch-shake {
  animation: shake-anim 0.4s steps(4);
}

@keyframes shake-anim {
  0% { transform: translate(0, 0); }
  25% { transform: translate(-3px, 2px); }
  50% { transform: translate(3px, -2px); }
  75% { transform: translate(-2px, -1px); }
  100% { transform: translate(0, 0); }
}

/* ===================================================
   走馬灯メモリダンプ（カーネルパニック後の暗い画面）
   =================================================== */
.lantern-overlay {
  position: absolute;
  inset: 0;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: radial-gradient(circle at center, #1d1a14 0%, #070605 100%);
  color: #efe6d2;
}

.lantern-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid rgba(255, 240, 210, 0.12);
}

.lantern-header .btn {
  min-height: 36px;
  padding: 0.2rem 0.8rem;
  font-size: 0.85rem;
}

.lantern-sys-log {
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  color: #d8b878;
  letter-spacing: 0.05em;
}

.lantern-center-stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  position: relative;
}

.lantern-start-card {
  text-align: center;
}

.lantern-start-card h2 {
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: 1.8rem;
  letter-spacing: 0.1em;
  margin-bottom: 0.5rem;
}

.lantern-start-card p {
  color: #b9ad96;
}

.lantern-memory-card {
  max-width: 560px;
  width: 100%;
  padding: 2rem 1.75rem;
  text-align: center;
  background: rgba(30, 26, 20, 0.92);
  border: 1px solid rgba(216, 184, 120, 0.45);
  box-shadow: 0 0 40px rgba(216, 184, 120, 0.18);
  animation: lantern-fade-in 0.8s ease-out;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
  align-items: center;
}

.lantern-memory-card.core-memory {
  border-color: #f2cf6b;
  box-shadow: 0 0 60px rgba(242, 207, 107, 0.3);
}

.lantern-memory-card.trivial-memory {
  border-color: rgba(255, 170, 68, 0.6);
}

.lantern-memory-card.ghost-memory {
  opacity: 0.55;
  border-style: dashed;
  border-color: rgba(239, 230, 210, 0.3);
  box-shadow: none;
  filter: blur(0.4px);
  animation: lantern-ghost 1s ease-out;
}

@keyframes lantern-ghost {
  from { opacity: 0; transform: translateX(-6px); }
  40% { opacity: 0.7; }
  to { opacity: 0.4; transform: translateX(6px); }
}

.lantern-badge {
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  padding: 0.15rem 0.8rem;
  background: rgba(255, 240, 210, 0.1);
  color: #efe6d2;
}

.lantern-memory-title {
  font-family: var(--font-pixel);
  font-weight: 400;
  font-size: 1.5rem;
  line-height: 1.4;
  color: #fff7e6;
}

.lantern-memory-desc {
  font-size: 0.95rem;
  color: #d9cfbb;
  line-height: 1.8;
}

.lantern-memory-size {
  font-family: var(--font-pixel);
  font-size: 0.85rem;
  color: #d8b878;
}

@keyframes lantern-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===================================================
   ヘルプ（LifeOS マニュアル）
   =================================================== */
.help-modal-card {
  width: min(620px, 100%);
}

.help-header {
  display: flex;
  flex-direction: column;
}

.help-badge {
  display: none;
}

.help-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 8px 0;
  padding: 8px;
  background: var(--field);
  box-shadow: var(--sunken);
  max-height: 60vh;
  overflow-y: auto;
}

.help-step-box {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.6rem 0.7rem;
  border-bottom: 1px dotted var(--face-lo);
}

.help-step-box:last-child {
  border-bottom: none;
}

.help-step-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.95rem;
}

.help-step-desc {
  font-size: 0.88rem;
  line-height: 1.65;
  color: var(--ink);
}

/* ===================================================
   容量達成時の手応え（確定バーを一度だけ点滅）
   =================================================== */
@keyframes commit-pulse-glow {
  0%, 100% { background: var(--face); }
  50% { background: var(--success-bg); }
}

.commit-pulse {
  animation: commit-pulse-glow 0.5s steps(2) 2;
}
