/*
Theme Name: Console BBS
Theme URI: https://360.nagoya/
Author: 360.nagoya
Description: パソコン通信（BBS）風のコンソール画面で動作するクラシックテーマ。投稿・固定ページを端末画面に1文字ずつ表示し、番号やコマンドで操作できます。文字色・通信速度・接続メッセージはカスタマイザーの「コンソール設定」で変更できます。
Version: 1.5.0
Requires at least: 6.3
Tested up to: 7.1
Requires PHP: 7.4
License: GNU General Public License v2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html
Text Domain: console-bbs
Tags: dark, one-column, custom-colors
*/

/* ---------- Color schemes ---------- */
:root {
	--fg: #33ff66;
	--dim: #1f9a40;
	--hi: #c8ffd6;
	--bg: #020b04;
	--err: #ff6b5c;
	--glow: rgba(51, 255, 102, 0.4);
	--gothic: "BIZ UDGothic", "Osaka-Mono", "MS Gothic", ui-monospace, monospace;
	--mincho: "BIZ UDMincho", "Hiragino Mincho ProN", "Yu Mincho", "MS Mincho", serif;
	--font: var(--gothic);
	--fs: clamp(14px, 0.6vw + 11px, 18px);
	--lh: 1.6;
	--bar-h: 2.4em;
	--admin: var(--wp-admin--admin-bar--height, 0px);
}

.scheme-amber {
	--fg: #ffb000;
	--dim: #a86f00;
	--hi: #ffe2a8;
	--bg: #0c0700;
	--err: #ff5c5c;
	--glow: rgba(255, 176, 0, 0.4);
}

.scheme-white {
	--fg: #e4e4e4;
	--dim: #8a8a8a;
	--hi: #ffffff;
	--bg: #0a0a0a;
	--err: #ff6b6b;
	--glow: rgba(228, 228, 228, 0.3);
}

.scheme-cyan {
	--fg: #4fe6ff;
	--dim: #2a8ea0;
	--hi: #d2f8ff;
	--bg: #010a0d;
	--err: #ff6b6b;
	--glow: rgba(79, 230, 255, 0.35);
}

/* ---------- Typeface (カスタマイザー「書体」) ---------- */
/* Mincho strokes are thin, so the glow is reduced to keep them readable. */
body.font-mincho {
	--font: var(--mincho);
	text-shadow: 0 0 1px var(--glow);
}

.font-mincho-body .entry-content {
	font-family: var(--mincho);
	text-shadow: 0 0 1px var(--glow);
}

/* Code and the image buttons stay in the terminal face. */
.font-mincho-body .entry-content pre,
.font-mincho-body .entry-content code,
.font-mincho-body .entry-content .img-ph {
	font-family: var(--gothic);
}

/* ---------- Base ---------- */
*,
*::before,
*::after {
	box-sizing: border-box;
}

html {
	background: var(--bg);
}

body {
	margin: 0;
	min-height: 100vh;
	background: var(--bg);
	color: var(--fg);
	font-family: var(--font);
	font-size: var(--fs);
	line-height: var(--lh);
	text-shadow: 0 0 1px var(--fg), 0 0 6px var(--glow);
	-webkit-font-smoothing: antialiased;
}

::selection {
	background: var(--fg);
	color: var(--bg);
	text-shadow: none;
}

a {
	color: var(--hi);
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

a:hover,
a:focus-visible {
	background: var(--fg);
	color: var(--bg);
	text-shadow: none;
	outline: none;
}

:focus-visible {
	outline: 2px dashed var(--fg);
	outline-offset: 2px;
}

.screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.skip-link:focus {
	position: fixed !important;
	top: calc(var(--admin) + 0.4em);
	left: 16px;
	z-index: 100;
	width: auto;
	height: auto;
	clip: auto;
	padding: 0.4em 0.8em;
	background: var(--fg);
	color: var(--bg);
}

/* ---------- CRT effect ---------- */
.cbbs-crt::before,
.cbbs-crt::after {
	content: "";
	position: fixed;
	inset: 0;
	pointer-events: none;
}

.cbbs-crt::before {
	z-index: 50;
	background: repeating-linear-gradient(
		to bottom,
		transparent 0,
		transparent 2px,
		rgba(0, 0, 0, 0.22) 3px,
		transparent 4px
	);
}

.cbbs-crt::after {
	z-index: 51;
	background: radial-gradient(ellipse at center, transparent 62%, rgba(0, 0, 0, 0.55) 100%);
	animation: cbbs-flicker 0.15s infinite alternate;
}

@keyframes cbbs-flicker {
	from { opacity: 1; }
	to { opacity: 0.97; }
}

/* ---------- Status bar & function keys ---------- */
.cbbs-status {
	position: fixed;
	top: var(--admin);
	left: 0;
	right: 0;
	z-index: 40;
	display: flex;
	gap: 1em;
	align-items: center;
	height: var(--bar-h);
	padding: 0 16px;
	background: var(--fg);
	color: var(--bg);
	text-shadow: none;
	font-size: 0.85em;
	white-space: nowrap;
	overflow: hidden;
}

.cbbs-status a {
	color: inherit;
	text-decoration: none;
	font-weight: 700;
}

.cbbs-status a:hover,
.cbbs-status a:focus-visible {
	background: var(--bg);
	color: var(--fg);
}

.cbbs-line-status {
	margin-left: auto;
}

.cbbs-fkeys {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 40;
	display: none;
	gap: 1px;
	padding-bottom: env(safe-area-inset-bottom);
	background: var(--dim);
	border-top: 1px solid var(--dim);
}

.cbbs-fkeys button {
	flex: 1;
	min-width: 0;
	padding: 0.7em 0.2em;
	border: 0;
	background: var(--bg);
	color: var(--fg);
	font: inherit;
	font-size: 0.8em;
	text-shadow: inherit;
	cursor: pointer;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.cbbs-fkeys button:hover,
.cbbs-fkeys button:focus-visible {
	background: var(--fg);
	color: var(--bg);
	text-shadow: none;
	outline: none;
}

.cbbs-fkeys kbd {
	font: inherit;
	color: var(--hi);
}

.cbbs-fkeys button:hover kbd,
.cbbs-fkeys button:focus-visible kbd {
	color: inherit;
}

/* ---------- Screen ---------- */
.cbbs-screen {
	max-width: 960px;
	margin: 0 auto;
	padding: calc(var(--bar-h) + 1.2em) 16px calc(var(--bar-h) + 3em);
	overflow-wrap: anywhere;
}

.cbbs-output {
	display: none;
}

.line {
	min-height: calc(var(--lh) * 1em);
	white-space: pre-wrap;
}

.dim,
.line.dim {
	color: var(--dim);
}

.line.hi,
.line.echo {
	color: var(--hi);
}

.line.err {
	color: var(--err);
}

.line.head {
	color: var(--hi);
	font-weight: 700;
}

.line.title {
	margin: 0.2em 0;
	color: var(--hi);
	font-size: 1.25em;
	font-weight: 700;
	line-height: 1.4;
}

.line.opt a,
.line.row a {
	color: var(--fg);
	text-decoration: none;
}

.line.row a {
	display: block;
}

.line.opt a:hover,
.line.opt a:focus-visible,
.line.row a:hover,
.line.row a:focus-visible {
	background: var(--fg);
	color: var(--bg);
}

.banner {
	margin: 0.6em 0;
	color: var(--hi);
	padding: 0.1em 0 0.3em;
	font-size: min(1.15em, 3.4vw);
	font-weight: 700;
	line-height: 1.3;
	white-space: pre;
	overflow-x: auto;
}

.rule {
	margin: 0.6em 0;
	border-top: 3px double var(--dim);
	box-shadow: 0 0 6px var(--glow);
}

/* Text rules (カスタマイザー「横棒」): the repeated characters are clipped to a whole
   number of character cells, so no half-cut glyph is left at the right edge. */
.rule-text .rule {
	width: 100%;
	width: round(down, 100%, 2ch);
	margin: 0.2em 0;
	border: 0;
	box-shadow: none;
	color: var(--dim);
	line-height: var(--lh);
	white-space: nowrap;
	overflow: hidden;
}

.rule-text .rule::before {
	content: var(--rule-str);
}

/* ---------- Input line ---------- */
.cbbs-form {
	display: none;
	align-items: baseline;
	gap: 0.5em;
	margin-top: 0.4em;
}

.cbbs-prompt {
	color: var(--hi);
	white-space: nowrap;
}

.cbbs-input {
	flex: 1;
	min-width: 0;
	padding: 0;
	border: 0;
	outline: none;
	background: transparent;
	color: var(--fg);
	font: inherit;
	font-size: max(16px, 1em);
	text-shadow: inherit;
	caret-color: var(--fg);
	caret-shape: block;
}

.cbbs-input::placeholder {
	color: var(--dim);
	opacity: 0.7;
}

.cbbs-busy .cbbs-form {
	opacity: 0.45;
}

/* JS on: terminal visible, server-rendered copy hidden (it is typed into the terminal). */
.js .cbbs-output {
	display: block;
}

.js .cbbs-form,
.js .cbbs-fkeys {
	display: flex;
}

.js .cbbs-static {
	display: none;
}

/* ---------- Server-rendered content ---------- */
.cbbs-title {
	margin: 0.2em 0;
	color: var(--hi);
	font-size: 1.25em;
	line-height: 1.4;
}

.cbbs-meta {
	margin: 0;
	color: var(--dim);
}

.cbbs-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.cbbs-list li {
	display: flex;
	gap: 1em;
}

.cbbs-list .no,
.cbbs-list time {
	flex: none;
	color: var(--dim);
}

.cbbs-nav {
	display: flex;
	flex-wrap: wrap;
	gap: 1em;
	margin-top: 1em;
}

.cbbs-searchform {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em;
	align-items: baseline;
}

.cbbs-searchform input,
.cbbs-searchform button {
	border: 1px solid var(--dim);
	background: transparent;
	color: var(--fg);
	font: inherit;
	padding: 0.2em 0.5em;
}

/* ---------- Post content ---------- */
.entry-content > :first-child {
	margin-top: 0;
}

.entry-content p {
	margin: 0 0 1em;
}

.entry-content h1,
.entry-content h2,
.entry-content h3,
.entry-content h4,
.entry-content h5,
.entry-content h6 {
	margin: 1.4em 0 0.4em;
	color: var(--hi);
	font-size: 1em;
	line-height: var(--lh);
}

.entry-content h1::before,
.entry-content h2::before { content: "■ "; }
.entry-content h3::before { content: "□ "; }
.entry-content h4::before,
.entry-content h5::before,
.entry-content h6::before { content: "・"; }

.entry-content ul {
	padding-left: 1.5em;
	list-style-type: "* ";
}

.entry-content ol {
	padding-left: 2em;
}

.entry-content blockquote {
	margin: 1em 0;
	padding-left: 1em;
	border-left: 2px solid var(--dim);
	color: var(--dim);
}

.entry-content pre,
.entry-content code {
	font-family: inherit;
}

.entry-content pre {
	padding: 0.6em;
	border: 1px dashed var(--dim);
	white-space: pre-wrap;
}

.entry-content code {
	color: var(--hi);
}

.entry-content hr {
	border: 0;
	border-top: 1px dashed var(--dim);
}

.entry-content img,
.entry-content video {
	max-width: 100%;
	height: auto;
	border: 1px solid var(--dim);
}

/* ---------- Images in the terminal ---------- */
.img-ph {
	display: inline-block;
	margin: 0.3em 0;
	padding: 0.1em 0.6em;
	border: 1px dashed var(--dim);
	background: none;
	color: var(--hi);
	font: inherit;
	text-align: left;
	text-shadow: inherit;
	cursor: pointer;
}

.img-ph:hover,
.img-ph:focus-visible {
	background: var(--fg);
	color: var(--bg);
	text-shadow: none;
	outline: none;
}

.aa {
	margin: 0.4em 0;
	overflow: hidden;
	font-family: var(--font);
	line-height: 1;
	letter-spacing: 0;
	white-space: pre;
	text-shadow: 0 0 2px var(--glow);
}

.orig {
	display: block;
	max-width: 100%;
	height: auto;
	margin: 0.6em 0 0.2em;
	border: 1px solid var(--dim);
}

.entry-content iframe {
	max-width: 100%;
	border: 1px solid var(--dim);
}

.entry-content figure {
	margin: 1em 0;
}

.entry-content figcaption {
	color: var(--dim);
	font-size: 0.9em;
}

.entry-content table {
	width: 100%;
	border-collapse: collapse;
}

.entry-content th,
.entry-content td {
	padding: 0.2em 0.5em;
	border: 1px solid var(--dim);
}

.entry-content .wp-block-button__link {
	display: inline-block;
	padding: 0.2em 0.8em;
	border: 1px solid var(--fg);
	background: none;
	color: var(--fg);
	text-decoration: none;
}

.alignleft { float: left; margin: 0 1em 1em 0; }
.alignright { float: right; margin: 0 0 1em 1em; }
.aligncenter { display: block; margin-left: auto; margin-right: auto; }

/* ---------- Responsive / preferences ---------- */
@media (max-width: 600px) {
	.cbbs-clock {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.cbbs-crt::after {
		animation: none;
	}
}

@media print {
	body {
		background: #fff;
		color: #000;
		text-shadow: none;
	}

	.cbbs-crt::before,
	.cbbs-crt::after,
	.cbbs-status,
	.cbbs-fkeys,
	.cbbs-form {
		display: none !important;
	}

	.cbbs-screen {
		padding: 0;
	}
}
