/*
 * labdocs.css
 * Modern document-style skin for PukiWiki
 * License: GPL v2 or (at your option) any later version
 */

/* ============================================================
   CSS Variables (Customization)
   ============================================================ */
:root {
	/* Colors */
	--color-bg: #fafafa;
	--color-surface: #ffffff;
	--color-text: #333333;
	--color-text-muted: #666666;
	--color-text-light: #888888;
	--color-primary: #2563eb;
	--color-primary-hover: #1d4ed8;
	--color-border: #e5e7eb;
	--color-border-light: #f0f0f0;

	/* Hero overlay */
	--hero-overlay-start: rgba(0, 0, 0, 0.3);
	--hero-overlay-end: rgba(0, 0, 0, 0.55);

	/* Layout */
	--sidebar-width: 280px;
	--content-max-width: 860px;
	--container-max-width: 1440px;
	--spacing-unit: 1rem;

	/* Card styles */
	--radius-card: 14px;
	--radius-small: 8px;
	--shadow-card: 0 1px 3px rgba(0, 0, 0, 0.08);
	--shadow-card-hover: 0 4px 12px rgba(0, 0, 0, 0.1);

	/* Typography */
	--font-sans: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", sans-serif;
	--font-mono: ui-monospace, "SF Mono", "Cascadia Code", "Source Code Pro", Menlo, Consolas, monospace;
	--line-height-body: 1.8;
	--line-height-heading: 1.4;
}

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

html {
	font-size: 16px;
	-webkit-text-size-adjust: 100%;
}

body {
	margin: 0;
	padding: 0;
	font-family: var(--font-sans);
	font-size: 1rem;
	line-height: var(--line-height-body);
	color: var(--color-text);
	background-color: var(--color-bg);
}

a {
	color: var(--color-primary);
	text-decoration: none;
}

a:hover {
	color: var(--color-primary-hover);
	text-decoration: underline;
}

img {
	max-width: 100%;
	height: auto;
}

/* ============================================================
   Header
   ============================================================ */
#header {
	background-color: var(--color-surface);
	border-bottom: 1px solid var(--color-border);
}

#header.with-hero {
	position: relative;
	background-image: var(--hero-image);
	background-size: cover;
	background-position: center;
	border-bottom: none;
	min-height: clamp(120px, 18vw, 200px);
}

#header.with-hero::before {
	content: '';
	position: absolute;
	inset: 0;
	background: linear-gradient(to bottom, var(--hero-overlay-start), var(--hero-overlay-end));
}

.header-inner {
	position: relative;
	z-index: 1;
	max-width: var(--container-max-width);
	margin: 0 auto;
	padding: calc(var(--spacing-unit) * 2) var(--spacing-unit);
}

#header.with-hero .header-inner {
	display: flex;
	flex-direction: column;
	justify-content: center;
	min-height: clamp(120px, 18vw, 200px);
	padding: calc(var(--spacing-unit) * 2);
}

.site-title {
	font-size: 1.5rem;
	font-weight: 700;
}

.site-title a {
	color: var(--color-text);
	text-decoration: none;
}

#header.with-hero .site-title a {
	color: #ffffff;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.site-subtitle {
	margin-top: 0.5rem;
	font-size: 1rem;
	color: rgba(255, 255, 255, 0.9);
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* ============================================================
   Page Title Bar
   ============================================================ */
#page-title-bar {
	background-color: var(--color-surface);
	border-bottom: 1px solid var(--color-border);
}

.page-title-inner {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 1rem;
	max-width: var(--container-max-width);
	margin: 0 auto;
	padding: var(--spacing-unit);
}

.page-title {
	margin: 0;
	font-size: 1.5rem;
	font-weight: 600;
	line-height: var(--line-height-heading);
	color: var(--color-text);
}

.page-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.75rem;
}

.page-actions a {
	font-size: 0.875rem;
	color: var(--color-text-muted);
	padding: 0.25rem 0.5rem;
	border-radius: var(--radius-small);
	transition: background-color 0.15s, color 0.15s;
}

.page-actions a:hover {
	color: var(--color-primary);
	background-color: var(--color-border-light);
	text-decoration: none;
}

/* ============================================================
   Layout Container (CSS Grid)
   ============================================================ */
.layout-container {
	display: grid;
	grid-template-columns: var(--sidebar-width) minmax(0, var(--content-max-width)) var(--sidebar-width);
	grid-template-areas: "left main right";
	gap: calc(var(--spacing-unit) * 2);
	max-width: var(--container-max-width);
	margin: 0 auto;
	padding: calc(var(--spacing-unit) * 2) var(--spacing-unit);
	justify-content: center;
}

.layout-container.no-menu {
	grid-template-columns: minmax(0, var(--content-max-width)) var(--sidebar-width);
	grid-template-areas: "main right";
}

.layout-container.no-rightbar {
	grid-template-columns: var(--sidebar-width) minmax(0, var(--content-max-width));
	grid-template-areas: "left main";
}

.layout-container.no-menu.no-rightbar {
	grid-template-columns: minmax(0, var(--content-max-width));
	grid-template-areas: "main";
}

/* ============================================================
   Sidebar
   ============================================================ */
.sidebar {
	min-width: 0;
}

.sidebar-left {
	grid-area: left;
}

.sidebar-right {
	grid-area: right;
}

.sidebar-content {
	background-color: var(--color-surface);
	border-radius: var(--radius-card);
	box-shadow: var(--shadow-card);
	padding: var(--spacing-unit);
}

/* Sidebar collapse (details/summary) */
.sidebar-collapse {
	background-color: var(--color-surface);
	border-radius: var(--radius-card);
	box-shadow: var(--shadow-card);
	overflow: hidden;
}

.sidebar-collapse > summary {
	display: none;
}

.sidebar-collapse > .sidebar-content,
.sidebar-collapse > nav.sidebar-content {
	border-radius: 0;
	box-shadow: none;
	display: block; /* PC時は常に表示 */
}

.sidebar-collapse[open] > .sidebar-content,
.sidebar-collapse[open] > nav.sidebar-content {
	display: block;
}

/* Sidebar inner content styling */
.sidebar-content ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

.sidebar-content li {
	margin: 0.25rem 0;
}

.sidebar-content li ul {
	margin-left: 1rem;
	margin-top: 0.25rem;
}

.sidebar-content a {
	display: block;
	padding: 0.375rem 0.5rem;
	border-radius: var(--radius-small);
	color: var(--color-text);
	transition: background-color 0.15s;
}

.sidebar-content a:hover {
	background-color: var(--color-border-light);
	text-decoration: none;
	color: var(--color-primary);
}

/* Sidebar headings */
.sidebar-content h2,
.sidebar-content h3,
.sidebar-content h4,
.sidebar-content h5 {
	margin: 1rem 0 0.5rem 0;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--color-text-muted);
	text-transform: uppercase;
	letter-spacing: 0.03em;
}

.sidebar-content h2:first-child,
.sidebar-content h3:first-child,
.sidebar-content h4:first-child,
.sidebar-content h5:first-child {
	margin-top: 0;
}

/* ============================================================
   Main Content
   ============================================================ */
#main-content {
	grid-area: main;
	min-width: 0;
}

#body {
	background-color: var(--color-surface);
	border-radius: var(--radius-card);
	box-shadow: var(--shadow-card);
	padding: calc(var(--spacing-unit) * 1.5);
}

/* ============================================================
   Typography (Body content)
   ============================================================ */
#body h2 {
	margin: 2rem 0 1rem 0;
	padding-bottom: 0.5rem;
	font-size: 1.5rem;
	font-weight: 600;
	line-height: var(--line-height-heading);
	border-bottom: 2px solid var(--color-primary);
}

#body h3 {
	margin: 1.75rem 0 0.75rem 0;
	padding-left: 0.75rem;
	font-size: 1.25rem;
	font-weight: 600;
	line-height: var(--line-height-heading);
	border-left: 4px solid var(--color-primary);
}

#body h4 {
	margin: 1.5rem 0 0.5rem 0;
	font-size: 1.1rem;
	font-weight: 600;
	line-height: var(--line-height-heading);
	color: var(--color-text);
}

#body h5 {
	margin: 1.25rem 0 0.5rem 0;
	font-size: 1rem;
	font-weight: 600;
	line-height: var(--line-height-heading);
	color: var(--color-text-muted);
}

#body h2:first-child,
#body h3:first-child,
#body h4:first-child,
#body h5:first-child {
	margin-top: 0;
}

#body p {
	margin: 0 0 1rem 0;
}

#body p:last-child {
	margin-bottom: 0;
}

/* Lists */
#body ul,
#body ol {
	margin: 0 0 1rem 0;
	padding-left: 1.5rem;
}

#body li {
	margin: 0.25rem 0;
}

#body li > ul,
#body li > ol {
	margin-top: 0.25rem;
	margin-bottom: 0;
}

/* Blockquote */
#body blockquote,
#body .quotation {
	margin: 1rem 0;
	padding: 0.75rem 1rem;
	border-left: 4px solid var(--color-border);
	background-color: var(--color-bg);
	border-radius: 0 var(--radius-small) var(--radius-small) 0;
	color: var(--color-text-muted);
}

#body blockquote p:last-child,
#body .quotation p:last-child {
	margin-bottom: 0;
}

/* Horizontal rule */
#body hr {
	margin: 2rem 0;
	border: none;
	border-top: 1px solid var(--color-border);
}

/* ============================================================
   Tables
   ============================================================ */
#body table {
	width: 100%;
	margin: 1rem 0;
	border-collapse: collapse;
	border-radius: var(--radius-small);
	overflow: hidden;
	box-shadow: 0 0 0 1px var(--color-border);
}

#body th,
#body td {
	padding: 0.75rem 1rem;
	text-align: left;
	border-bottom: 1px solid var(--color-border);
}

#body th {
	background-color: var(--color-bg);
	font-weight: 600;
	color: var(--color-text);
}

#body tr:last-child td {
	border-bottom: none;
}

#body tbody tr:nth-child(even) {
	background-color: var(--color-border-light);
}

/* Responsive table wrapper */
#body .table-wrapper {
	overflow-x: auto;
	margin: 1rem 0;
}

/* ============================================================
   Code
   ============================================================ */
#body code {
	padding: 0.15rem 0.4rem;
	font-family: var(--font-mono);
	font-size: 0.9em;
	background-color: var(--color-bg);
	border-radius: 4px;
}

#body pre {
	margin: 1rem 0;
	padding: 1rem;
	font-family: var(--font-mono);
	font-size: 0.9rem;
	line-height: 1.5;
	background-color: #1e1e1e;
	color: #d4d4d4;
	border-radius: var(--radius-small);
	overflow-x: auto;
}

#body pre code {
	padding: 0;
	background-color: transparent;
	border-radius: 0;
	color: inherit;
}

/* ============================================================
   Notes & Attachments
   ============================================================ */
.notes-section,
.attach-section {
	margin-top: calc(var(--spacing-unit) * 1.5);
	padding: var(--spacing-unit);
	background-color: var(--color-surface);
	border-radius: var(--radius-card);
	box-shadow: var(--shadow-card);
}

.attach-section h2 {
	margin: 0 0 1rem 0;
	font-size: 1rem;
	font-weight: 600;
	color: var(--color-text-muted);
}

/* ============================================================
   Site Navigation
   ============================================================ */
#site-nav {
	background-color: var(--color-surface);
	border-top: 1px solid var(--color-border);
	border-bottom: 1px solid var(--color-border);
	margin-top: calc(var(--spacing-unit) * 2);
}

.site-nav-inner {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5rem 1.5rem;
	max-width: var(--container-max-width);
	margin: 0 auto;
	padding: var(--spacing-unit);
}

#site-nav a {
	font-size: 0.9rem;
	color: var(--color-text-muted);
	padding: 0.25rem 0;
}

#site-nav a:hover {
	color: var(--color-primary);
}

#site-nav .rss-link {
	color: #f97316;
}

/* ============================================================
   Footer
   ============================================================ */
#footer {
	max-width: var(--container-max-width);
	margin: 0 auto;
	padding: calc(var(--spacing-unit) * 2) var(--spacing-unit);
	text-align: center;
	font-size: 0.875rem;
	color: var(--color-text-light);
}

.last-modified,
.related-pages {
	margin-bottom: 0.5rem;
}

.footer-info {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 0.5rem 1.5rem;
}

#footer a {
	color: var(--color-text-muted);
}

#footer a:hover {
	color: var(--color-primary);
}

/* ============================================================
   Photo Card Plugin
   ============================================================ */
.photocard {
	display: flex;
	gap: 1.5rem;
	margin: 1.5rem 0;
	padding: 1.25rem;
	background-color: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-card);
	box-shadow: var(--shadow-card);
	transition: box-shadow 0.2s;
}

.photocard:hover {
	box-shadow: var(--shadow-card-hover);
}

.photocard-image {
	flex-shrink: 0;
	width: 200px;
}

.photocard-image img {
	width: 100%;
	height: auto;
	border-radius: var(--radius-small);
	object-fit: cover;
}

.photocard-content {
	flex: 1;
	min-width: 0;
}

.photocard-title {
	margin: 0 0 0.75rem 0;
	font-size: 1.1rem;
	font-weight: 600;
	line-height: var(--line-height-heading);
	color: var(--color-text);
}

.photocard-title a {
	color: inherit;
}

.photocard-title a:hover {
	color: var(--color-primary);
}

.photocard-body {
	font-size: 0.95rem;
	color: var(--color-text);
}

.photocard-body p {
	margin: 0 0 0.5rem 0;
}

.photocard-body p:last-child {
	margin-bottom: 0;
}

/* Photo card - vertical layout option */
.photocard.photocard-vertical {
	flex-direction: column;
}

.photocard.photocard-vertical .photocard-image {
	width: 100%;
}

/* ============================================================
   News Excerpt Plugin
   ============================================================ */
.newsexcerpt {
	display: flex;
	flex-direction: column;
	gap: 1rem;
}

.newsexcerpt-item {
	padding: 1.25rem;
	background-color: var(--color-surface);
	border: 1px solid var(--color-border);
	border-radius: var(--radius-card);
	box-shadow: var(--shadow-card);
	transition: box-shadow 0.2s;
}

.newsexcerpt-item:hover {
	box-shadow: var(--shadow-card-hover);
}

.newsexcerpt-title {
	margin: 0 0 0.5rem 0;
	font-size: 1.1rem;
	font-weight: 600;
	line-height: var(--line-height-heading);
}

.newsexcerpt-title a {
	color: var(--color-text);
}

.newsexcerpt-title a:hover {
	color: var(--color-primary);
}

.newsexcerpt-body {
	margin-bottom: 0.75rem;
	font-size: 0.95rem;
	color: var(--color-text-muted);
	line-height: 1.6;
}

.newsexcerpt-more {
	display: inline-block;
	font-size: 0.875rem;
	color: var(--color-primary);
}

.newsexcerpt-more:hover {
	text-decoration: underline;
}

/* ============================================================
   PukiWiki Specific Overrides
   ============================================================ */

/* Hide jump menu (back to top arrows between sections) */
.jumpmenu {
	display: none;
}

/* Edit form */
#body textarea {
	width: 100%;
	min-height: 400px;
	padding: 0.75rem;
	font-family: var(--font-mono);
	font-size: 0.95rem;
	line-height: 1.5;
	border: 1px solid var(--color-border);
	border-radius: var(--radius-small);
	resize: vertical;
}

#body input[type="text"],
#body input[type="password"] {
	padding: 0.5rem 0.75rem;
	font-size: 1rem;
	border: 1px solid var(--color-border);
	border-radius: var(--radius-small);
}

#body input[type="submit"],
#body button {
	padding: 0.5rem 1rem;
	font-size: 0.95rem;
	color: #ffffff;
	background-color: var(--color-primary);
	border: none;
	border-radius: var(--radius-small);
	cursor: pointer;
	transition: background-color 0.15s;
}

#body input[type="submit"]:hover,
#body button:hover {
	background-color: var(--color-primary-hover);
}

/* Diff view */
#body .diff_added {
	background-color: #dcfce7;
}

#body .diff_removed {
	background-color: #fee2e2;
}

/* Search results */
#body .search-result {
	margin: 1rem 0;
	padding: 1rem;
	background-color: var(--color-bg);
	border-radius: var(--radius-small);
}

/* Recent changes list */
#body ul.recent_list {
	list-style: none;
	padding-left: 0;
}

#body ul.recent_list li {
	padding: 0.5rem 0;
	border-bottom: 1px solid var(--color-border-light);
}

#body ul.recent_list li:last-child {
	border-bottom: none;
}

/* ============================================================
   Responsive Design
   ============================================================ */

/* Tablet (768px - 1023px) */
@media screen and (max-width: 1023px) {
	:root {
		--sidebar-width: 240px;
	}

	.layout-container {
		grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
		grid-template-areas:
			"left main"
			"left right";
	}

	.layout-container.no-menu {
		grid-template-columns: minmax(0, 1fr);
		grid-template-areas:
			"main"
			"right";
	}

	.sidebar-right {
		grid-column: 2;
	}

	.layout-container.no-menu .sidebar-right {
		grid-column: 1;
	}
}

/* Mobile (767px and below) */
@media screen and (max-width: 767px) {
	:root {
		--spacing-unit: 0.875rem;
	}

	.layout-container {
		grid-template-columns: 1fr;
		grid-template-areas:
			"left"
			"main"
			"right";
		gap: var(--spacing-unit);
	}

	.layout-container.no-menu {
		grid-template-areas:
			"main"
			"right";
	}

	.layout-container.no-rightbar {
		grid-template-areas:
			"left"
			"main";
	}

	.layout-container.no-menu.no-rightbar {
		grid-template-areas: "main";
	}

	/* Reset sidebar-right grid-column from tablet setting */
	.sidebar-right {
		grid-column: auto;
	}

	/* Show summary on mobile */
	.sidebar-collapse > summary {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 0.75rem 1rem;
		font-weight: 600;
		color: var(--color-text);
		cursor: pointer;
		user-select: none;
		list-style: none;
		border-bottom: 1px solid var(--color-border-light);
	}

	.sidebar-collapse > summary::-webkit-details-marker {
		display: none;
	}

	.sidebar-collapse > summary::after {
		content: '+';
		font-size: 1.25rem;
		font-weight: 400;
		color: var(--color-text-muted);
		line-height: 1;
	}

	.sidebar-collapse[open] > summary::after {
		content: '−';
	}

	.sidebar-collapse[open] > summary {
		border-bottom: none;
	}

	/* Collapse sidebars by default on mobile */
	.sidebar-collapse:not([open]) > .sidebar-content,
	.sidebar-collapse:not([open]) > nav.sidebar-content {
		display: none;
	}

	/* Page title */
	.page-title {
		font-size: 1.25rem;
	}

	.page-actions {
		width: 100%;
	}

	/* Photo card vertical on mobile */
	.photocard {
		flex-direction: column;
	}

	.photocard-image {
		width: 100%;
	}

	/* Tables scroll */
	#body table {
		display: block;
		overflow-x: auto;
	}
}

/* Small mobile (480px and below) */
@media screen and (max-width: 480px) {
	html {
		font-size: 15px;
	}

	#header.with-hero {
		min-height: 100px;
	}

	#header.with-hero .header-inner {
		min-height: 100px;
	}

	.site-title {
		font-size: 1.25rem;
	}

	#body {
		padding: var(--spacing-unit);
	}

	#body h2 {
		font-size: 1.3rem;
	}

	#body h3 {
		font-size: 1.15rem;
	}
}

/* ============================================================
   Print Styles
   ============================================================ */
@media print {
	#header,
	#site-nav,
	.sidebar,
	.page-actions,
	#footer {
		display: none !important;
	}

	.layout-container {
		display: block;
	}

	#body {
		box-shadow: none;
		padding: 0;
	}

	a {
		color: inherit;
		text-decoration: underline;
	}

	a[href]::after {
		content: " (" attr(href) ")";
		font-size: 0.8em;
		color: #666;
	}

	a[href^="#"]::after,
	a[href^="javascript:"]::after {
		content: "";
	}
}
