/* styles.css
   The grimoire's binding. Dark vellum, amber ink, teal glow. */

:root {
	--amber: #C49A6C;
	--teal: #7EBDC2;
	--body: #B8B0A0;
	--bg: #0a0a0e;
	--ink: #16141c;
	--parchment: #e8e0cd;
}

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

html, body {
	height: 100%;
	overflow: hidden;
	background: var(--bg);
	color: var(--body);
	font-family: Georgia, 'Times New Roman', serif;
}

#scene {
	position: fixed;
	inset: 0;
	width: 100%;
	height: 100%;
	display: block;
	cursor: grab;
	touch-action: none;
}

/* faint vignette + scanlines over everything, very subtle */
body::after {
	content: "";
	position: fixed;
	inset: 0;
	pointer-events: none;
	z-index: 200;
	background:
		repeating-linear-gradient(0deg, rgba(0,0,0,0.08) 0 1px, transparent 1px 3px),
		radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.55) 100%);
	mix-blend-mode: multiply;
}

/* ---------------- intro ---------------- */
#intro {
	position: fixed;
	inset: 0;
	z-index: 100;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	text-align: center;
	background: radial-gradient(ellipse at 50% 40%, #11101a 0%, var(--bg) 70%);
	transition: opacity 0.9s ease;
	padding: 24px;
}
#intro.gone { opacity: 0; pointer-events: none; }
#intro .sigil {
	font-size: 64px;
	color: var(--amber);
	text-shadow: 0 0 28px rgba(196,154,108,0.6);
	animation: breathe 4s ease-in-out infinite;
}
@keyframes breathe {
	0%, 100% { transform: scale(1); opacity: 0.85; }
	50% { transform: scale(1.07); opacity: 1; }
}
#intro h1 {
	margin-top: 18px;
	font-size: clamp(28px, 5vw, 48px);
	letter-spacing: 0.14em;
	font-weight: normal;
	color: var(--parchment);
}
#intro .sub {
	margin-top: 10px;
	color: var(--amber);
	font-style: italic;
	letter-spacing: 0.06em;
}
#intro .whisper {
	margin-top: 26px;
	max-width: 460px;
	line-height: 1.7;
	color: var(--body);
	font-size: 15px;
}
#intro .buttons { margin-top: 34px; display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
#intro button {
	font-family: inherit;
	font-size: 15px;
	letter-spacing: 0.08em;
	padding: 12px 26px;
	background: transparent;
	color: var(--amber);
	border: 1px solid rgba(196,154,108,0.5);
	cursor: pointer;
	transition: all 0.25s ease;
}
#intro button:hover {
	background: rgba(196,154,108,0.12);
	box-shadow: 0 0 22px rgba(196,154,108,0.25);
}
#intro button.quiet { border-color: rgba(184,176,160,0.25); color: var(--body); font-size: 13px; padding: 10px 18px; }
#intro .controls-hint {
	margin-top: 30px;
	font-size: 12px;
	color: rgba(184,176,160,0.55);
	letter-spacing: 0.06em;
}

/* ---------------- HUD ---------------- */
#hud-name {
	position: fixed;
	top: 18px;
	left: 22px;
	z-index: 50;
	color: var(--parchment);
	letter-spacing: 0.18em;
	font-size: 13px;
	text-transform: uppercase;
}
#hud-name small { display: block; color: var(--amber); font-size: 10px; letter-spacing: 0.14em; margin-top: 4px; font-style: italic; text-transform: none; }

#hud-buttons {
	position: fixed;
	top: 16px;
	right: 18px;
	z-index: 50;
	display: flex;
	gap: 8px;
}
#hud-buttons button {
	font-family: Georgia, serif;
	font-size: 12px;
	padding: 7px 12px;
	background: rgba(10,10,14,0.7);
	color: var(--body);
	border: 1px solid rgba(184,176,160,0.25);
	cursor: pointer;
	transition: all 0.2s;
}
#hud-buttons button:hover, #hud-buttons button.active { color: var(--amber); border-color: rgba(196,154,108,0.55); }

#nav-chips {
	position: fixed;
	bottom: 18px;
	left: 50%;
	transform: translateX(-50%);
	z-index: 50;
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
	justify-content: center;
	max-width: 94vw;
}
#nav-chips button {
	font-family: Georgia, serif;
	font-size: 12px;
	letter-spacing: 0.05em;
	padding: 7px 13px;
	background: rgba(10,10,14,0.72);
	color: var(--body);
	border: 1px solid rgba(184,176,160,0.2);
	border-radius: 16px;
	cursor: pointer;
	transition: all 0.2s;
}
#nav-chips button:hover { color: var(--amber); border-color: rgba(196,154,108,0.5); box-shadow: 0 0 14px rgba(196,154,108,0.18); }

#egg-count {
	position: fixed;
	bottom: 18px;
	right: 18px;
	z-index: 50;
	font-size: 13px;
	color: var(--amber);
	background: rgba(10,10,14,0.7);
	border: 1px solid rgba(196,154,108,0.35);
	padding: 7px 12px;
	border-radius: 16px;
	opacity: 0;
	transform: translateY(8px);
	transition: all 0.5s ease;
}
#egg-count.visible { opacity: 1; transform: none; }

#tip {
	position: fixed;
	z-index: 60;
	pointer-events: none;
	font-size: 13px;
	font-style: italic;
	color: var(--parchment);
	background: rgba(10,10,14,0.85);
	border: 1px solid rgba(196,154,108,0.4);
	padding: 5px 10px;
	opacity: 0;
	transition: opacity 0.15s;
	white-space: nowrap;
}
#tip.show { opacity: 1; }

/* ---------------- panel (grimoire pages) ---------------- */
#panel {
	position: fixed;
	top: 0;
	right: 0;
	height: 100%;
	width: min(480px, 94vw);
	z-index: 70;
	background: linear-gradient(160deg, rgba(22,19,26,0.97), rgba(12,11,16,0.97));
	border-left: 1px solid rgba(196,154,108,0.35);
	box-shadow: -20px 0 60px rgba(0,0,0,0.6);
	transform: translateX(105%);
	transition: transform 0.45s cubic-bezier(0.22, 1, 0.36, 1);
	display: flex;
	flex-direction: column;
}
#panel.open { transform: none; }
#panel header {
	padding: 26px 30px 18px;
	border-bottom: 1px solid rgba(196,154,108,0.2);
}
#panel-eyebrow {
	font-size: 11px;
	letter-spacing: 0.22em;
	text-transform: uppercase;
	color: var(--amber);
}
#panel-title {
	margin-top: 8px;
	font-size: 26px;
	font-weight: normal;
	color: var(--parchment);
}
#panel-close {
	position: absolute;
	top: 16px;
	right: 16px;
	background: none;
	border: 1px solid rgba(184,176,160,0.25);
	color: var(--body);
	font-size: 14px;
	width: 30px;
	height: 30px;
	cursor: pointer;
}
#panel-close:hover { color: var(--amber); border-color: var(--amber); }
#panel-body {
	padding: 22px 30px 40px;
	overflow-y: auto;
	line-height: 1.75;
	font-size: 14.5px;
}
#panel-body::-webkit-scrollbar { width: 8px; }
#panel-body::-webkit-scrollbar-thumb { background: rgba(196,154,108,0.3); }
#panel-body h3 {
	margin: 26px 0 8px;
	font-weight: normal;
	color: var(--amber);
	font-size: 16px;
	letter-spacing: 0.06em;
}
#panel-body p { margin: 10px 0; }
#panel-body a { color: var(--teal); text-decoration: none; border-bottom: 1px dotted rgba(126,189,194,0.5); }
#panel-body a:hover { color: #a8dbe0; border-bottom-style: solid; }
#panel-body ul { margin: 10px 0 10px 20px; }
#panel-body li { margin: 5px 0; }
#panel-body .lead { font-size: 16px; font-style: italic; color: var(--parchment); }
#panel-body .aside {
	margin: 18px 0;
	padding: 12px 16px;
	border-left: 2px solid rgba(196,154,108,0.5);
	background: rgba(196,154,108,0.06);
	font-size: 13px;
	font-style: italic;
	color: rgba(184,176,160,0.9);
}
#panel-body .stat-row { display: flex; gap: 12px; flex-wrap: wrap; margin: 16px 0; }
#panel-body .stat {
	flex: 1 1 100px;
	border: 1px solid rgba(196,154,108,0.25);
	padding: 10px 12px;
	text-align: center;
}
#panel-body .stat b { display: block; font-size: 20px; color: var(--amber); font-weight: normal; }
#panel-body .stat span { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(184,176,160,0.7); }
#panel-body .workings dt { color: var(--teal); margin-top: 12px; font-size: 14px; }
#panel-body .workings dd { margin-left: 0; font-size: 13.5px; color: rgba(184,176,160,0.92); }
#panel-body code {
	font-family: 'Courier New', monospace;
	font-size: 12.5px;
	background: rgba(126,189,194,0.1);
	color: var(--teal);
	padding: 1px 5px;
}

/* ---------------- terminal window ---------------- */
#terminal-window {
	position: fixed;
	z-index: 80;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%) scale(0.92);
	width: min(820px, 95vw);
	height: min(620px, 90vh);
	background: #050805;
	border: 1px solid rgba(126,189,194,0.45);
	box-shadow: 0 0 60px rgba(126,189,194,0.18), 0 30px 80px rgba(0,0,0,0.7);
	opacity: 0;
	pointer-events: none;
	transition: all 0.35s ease;
	display: flex;
	flex-direction: column;
}
#terminal-window.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
#terminal-bar {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 12px;
	background: rgba(126,189,194,0.08);
	border-bottom: 1px solid rgba(126,189,194,0.3);
	font-family: 'Courier New', monospace;
	font-size: 12px;
	color: var(--teal);
	letter-spacing: 0.08em;
}
#terminal-bar .dot { width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(126,189,194,0.5); }
#terminal-bar .title { flex: 1; text-align: center; }
#terminal-bar button {
	background: none;
	border: 1px solid rgba(126,189,194,0.35);
	color: var(--teal);
	font-family: inherit;
	font-size: 11px;
	padding: 3px 9px;
	cursor: pointer;
}
#terminal-bar button:hover { background: rgba(126,189,194,0.15); }
#terminal-mount { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* zork internals (mounted by zork.js) */
.zk-log {
	flex: 1;
	overflow-y: auto;
	padding: 16px 18px;
	font-family: 'Courier New', monospace;
	font-size: 13.5px;
	line-height: 1.55;
	color: #9fe8d8;
	text-shadow: 0 0 6px rgba(126,189,194,0.35);
}
.zk-log::-webkit-scrollbar { width: 8px; }
.zk-log::-webkit-scrollbar-thumb { background: rgba(126,189,194,0.3); }
.zk-line { white-space: pre-wrap; word-wrap: break-word; margin: 2px 0; }
.zk-line.title { color: #d8f3ec; font-weight: bold; }
.zk-line.subtitle, .zk-line.dim { color: rgba(159,232,216,0.55); }
.zk-line.room { color: var(--parchment); font-weight: bold; letter-spacing: 0.04em; }
.zk-line.npc { color: var(--amber); }
.zk-line.item { color: #e8d8a0; }
.zk-line.hint { color: rgba(159,232,216,0.7); font-style: italic; }
.zk-line.error { color: #e08a7a; }
.zk-line.cmd { color: rgba(216,243,236,0.9); }
.zk-input-row {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 10px 18px;
	border-top: 1px solid rgba(126,189,194,0.25);
	font-family: 'Courier New', monospace;
}
.zk-prompt { color: var(--teal); font-size: 14px; }
.zk-input {
	flex: 1;
	background: transparent;
	border: none;
	outline: none;
	color: #d8f3ec;
	font-family: 'Courier New', monospace;
	font-size: 14px;
	text-shadow: 0 0 6px rgba(126,189,194,0.35);
}

/* ---------------- toasts ---------------- */
#toasts {
	position: fixed;
	left: 18px;
	bottom: 64px;
	z-index: 90;
	display: flex;
	flex-direction: column;
	gap: 10px;
	max-width: min(420px, 86vw);
	pointer-events: none;
}
.toast {
	background: rgba(14,13,18,0.94);
	border: 1px solid rgba(184,176,160,0.3);
	border-left: 3px solid var(--amber);
	padding: 12px 16px;
	font-size: 13.5px;
	line-height: 1.6;
	color: var(--body);
	opacity: 0;
	transform: translateX(-14px);
	transition: all 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}
.toast.show { opacity: 1; transform: none; }
.toast b { color: var(--parchment); font-weight: normal; }
.toast .dim { color: rgba(184,176,160,0.6); }
.toast.egg { border-left-color: var(--amber); box-shadow: 0 0 24px rgba(196,154,108,0.18); }
.toast.rune { border-left-color: var(--teal); }
.toast.raven { border-left-color: #444; font-style: italic; }
.toast.eldritch { border-left-color: #3f9d78; color: #a8d8c2; }
.toast.wild { border-left-color: #9fe8d8; }

/* ---------------- help ---------------- */
#help {
	position: fixed;
	inset: 0;
	z-index: 85;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(5,5,8,0.8);
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s;
}
#help.open { opacity: 1; pointer-events: auto; }
#help .card {
	width: min(520px, 92vw);
	max-height: 86vh;
	overflow-y: auto;
	background: rgba(18,16,22,0.98);
	border: 1px solid rgba(196,154,108,0.4);
	padding: 28px 32px;
	line-height: 1.8;
	font-size: 14px;
}
#help h2 { font-weight: normal; color: var(--parchment); letter-spacing: 0.1em; font-size: 20px; }
#help h3 { font-weight: normal; color: var(--amber); margin-top: 18px; font-size: 15px; }
#help kbd {
	font-family: 'Courier New', monospace;
	font-size: 12px;
	border: 1px solid rgba(184,176,160,0.4);
	padding: 1px 6px;
	border-radius: 3px;
	color: var(--parchment);
}
#help .riddles { font-style: italic; color: rgba(184,176,160,0.75); font-size: 13px; }
#help button {
	margin-top: 20px;
	font-family: inherit;
	padding: 9px 20px;
	background: none;
	border: 1px solid rgba(196,154,108,0.5);
	color: var(--amber);
	cursor: pointer;
}

/* ---------------- konami wizard console ---------------- */
#konami-menu {
	position: fixed;
	z-index: 95;
	left: 50%;
	top: 50%;
	transform: translate(-50%, -50%) scale(0.95);
	width: min(440px, 92vw);
	max-height: 86vh;
	overflow-y: auto;
	background: #060a06;
	border: 2px solid #3fbf6f;
	box-shadow: 0 0 50px rgba(63,191,111,0.25);
	padding: 22px 24px;
	font-family: 'Courier New', monospace;
	color: #5fdf8f;
	opacity: 0;
	pointer-events: none;
	transition: all 0.25s;
}
#konami-menu.open { opacity: 1; pointer-events: auto; transform: translate(-50%, -50%) scale(1); }
#konami-menu h3 { font-size: 16px; letter-spacing: 0.12em; }
#konami-menu .km-sub { font-size: 10px; color: rgba(95,223,143,0.55); margin: 4px 0 16px; }
#konami-menu h4 { margin: 18px 0 8px; font-size: 12px; letter-spacing: 0.1em; color: rgba(95,223,143,0.8); }
.km-row {
	display: flex;
	justify-content: space-between;
	width: 100%;
	background: none;
	border: 1px solid rgba(63,191,111,0.35);
	color: #5fdf8f;
	font-family: inherit;
	font-size: 13px;
	padding: 8px 12px;
	margin: 4px 0;
	cursor: pointer;
	text-align: left;
}
.km-row:hover { background: rgba(63,191,111,0.12); }
.km-ledger { list-style: none; font-size: 11.5px; columns: 2; column-gap: 18px; }
.km-ledger li { margin: 3px 0; color: rgba(95,223,143,0.4); break-inside: avoid; }
.km-ledger li.got { color: #5fdf8f; }
.km-close { margin-top: 14px; }

/* ---------------- pip-boy mode ---------------- */
body.pipboy #scene { filter: sepia(1) hue-rotate(70deg) saturate(2.4) brightness(0.92) contrast(1.15); }
body.pipboy::after {
	background:
		repeating-linear-gradient(0deg, rgba(0,40,0,0.22) 0 2px, transparent 2px 4px),
		radial-gradient(ellipse at center, transparent 50%, rgba(0,20,0,0.6) 100%);
}
body.pipboy #hud-name, body.pipboy #hud-name small { color: #5fdf8f; }

/* ---------------- eldritch flare ---------------- */
body.eldritch #scene { filter: saturate(1.2) hue-rotate(-8deg); }
body.eldritch.pipboy #scene { filter: sepia(1) hue-rotate(70deg) saturate(2.4) brightness(0.92) contrast(1.15); }

/* ---------------- zoom buttons (touch) ---------------- */
#zoom-ctl {
	position: fixed;
	right: 12px;
	top: 50%;
	transform: translateY(-50%);
	z-index: 50;
	display: none;
	flex-direction: column;
	gap: 12px;
}
#zoom-ctl button {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: rgba(10,10,14,0.72);
	border: 1px solid rgba(184,176,160,0.3);
	color: var(--body);
	font-size: 24px;
	line-height: 1;
	font-family: Georgia, serif;
	cursor: pointer;
	touch-action: manipulation;
}
#zoom-ctl button:active { color: var(--amber); border-color: rgba(196,154,108,0.55); }
@media (pointer: coarse) {
	#zoom-ctl { display: flex; }
}

/* ---------------- an old controller (mobile konami) ---------------- */
#hud-name { user-select: none; -webkit-user-select: none; }
#konami-pad {
	position: fixed;
	left: 50%;
	bottom: 120px;
	transform: translateX(-50%) translateY(20px);
	z-index: 160;
	background: rgba(12,11,18,0.96);
	border: 1px solid rgba(196,154,108,0.4);
	border-radius: 12px;
	padding: 14px 18px 12px;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.25s ease, transform 0.25s ease;
	text-align: center;
	box-shadow: 0 10px 44px rgba(0,0,0,0.65);
	user-select: none;
	-webkit-user-select: none;
}
#konami-pad.open { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
#konami-pad .kp-title { color: var(--amber); font-size: 11px; letter-spacing: 0.18em; margin-bottom: 10px; }
#konami-pad .kp-row { display: flex; align-items: center; justify-content: center; gap: 26px; }
#konami-pad .kp-dpad { display: grid; grid-template-columns: 48px 48px 48px; grid-template-rows: 48px 48px 48px; gap: 2px; }
#konami-pad .kp-up { grid-column: 2; grid-row: 1; }
#konami-pad .kp-left { grid-column: 1; grid-row: 2; }
#konami-pad .kp-right { grid-column: 3; grid-row: 2; }
#konami-pad .kp-down { grid-column: 2; grid-row: 3; }
#konami-pad button {
	font-family: Georgia, serif;
	background: rgba(184,176,160,0.08);
	border: 1px solid rgba(184,176,160,0.3);
	color: var(--body);
	font-size: 18px;
	cursor: pointer;
	touch-action: manipulation;
	transition: background 0.12s, color 0.12s;
}
#konami-pad .kp-ab { display: flex; gap: 10px; }
#konami-pad .kp-ab button {
	width: 54px;
	height: 54px;
	border-radius: 50%;
	color: var(--amber);
	border-color: rgba(196,154,108,0.45);
	font-size: 17px;
}
#konami-pad button.hit { background: rgba(196,154,108,0.35); color: var(--parchment); }
#konami-pad .kp-hint { margin-top: 10px; font-size: 10px; font-style: italic; color: rgba(184,176,160,0.55); }
#konami-pad .kp-close { margin-top: 8px; font-size: 11px; padding: 6px 14px; border-radius: 14px; }

/* ---------------- small screens ---------------- */
@media (max-width: 640px) {
	#hud-name { font-size: 11px; }
	#hud-buttons button { font-size: 13px; padding: 11px 14px; }
	#nav-chips {
		bottom: 10px;
		left: 0;
		right: 0;
		transform: none;
		max-width: 100vw;
		flex-wrap: nowrap;
		justify-content: flex-start;
		overflow-x: auto;
		padding: 6px 12px;
		gap: 8px;
		-webkit-overflow-scrolling: touch;
		scrollbar-width: none;
	}
	#nav-chips::-webkit-scrollbar { display: none; }
	#nav-chips button { font-size: 13px; padding: 11px 16px; flex: 0 0 auto; }
	#egg-count { bottom: 70px; }
	#toasts { bottom: 118px; }
	#panel { width: 100vw; }
	#konami-pad { bottom: 86px; }
}

/* ---------------- reduced motion courtesy ---------------- */
@media (prefers-reduced-motion: reduce) {
	#intro .sigil { animation: none; }
}
