/* ==========================================================================
   ResearchOps UI • Reflexive Journal styles
   Version:    v1.0.1-beta
   Service:    Home Office Biometrics — ResearchOps
   Author:     Kevin Rapley
   Date:       2025-10-23
   Build:      GOV.UK typography + colours; mobile-first
   Repo:       /css/journal.css
   License:    All rights reserved
   Purpose:    Journal entry cards, filters, and category-based theming
   Standards:  GOV.UK colours; mobile-first; WCAG 2.2 AA
   NAV KEY:    "="  (Find "=" to jump sections)
   ========================================================================== 
*/

/* CSS DIRECTORY
	1. =JOURNAL
	2. =CODING INTERFACE
	3. =CODEBOOK TREE
	4. =CAQDAS INTERFACE
	5. =RESPONSIVE
*/

/* === =JOURNAL ============================================ */

.journal-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: var(--space-400);
	flex-wrap: wrap;
	gap: var(--space-200);
	}

.journal-header h1 {
	margin: 0;
	}

#journals-tabs {
	margin-top: 24px;
	margin-bottom: 24px;
	}

#journals-tabs .govuk-heading-m {
	margin-top: 0;
	}

#journals-tabs .filter-chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	}

#journals-tabs .filter-chip {
	border: 1px solid #b1b4b6;
	background: #fff;
	border-radius: 20px;
	padding: 6px 12px;
	font-size: 16px;
	line-height: 1.3;
	cursor: pointer;
	}

#journals-tabs .filter-chip:hover {
	background: #f3f2f1;
	}

#journals-tabs .filter-chip--active {
	border-color: #1d70b8;
	box-shadow: inset 0 0 0 1px #1d70b8;
	}

#journals-tabs .journal-filters {
	margin-bottom: 24px;
	}

.visually-hidden {
	position: absolute !important;
	width: 1px !important;
	height: 1px !important;
	margin: -1px !important;
	padding: 0 !important;
	overflow: hidden !important;
	clip: rect(0 0 0 0) !important;
	border: 0 !important;
	}

.filter-group {
	display: flex;
	gap: var(--space-200);
	flex-wrap: wrap;
	margin-bottom: var(--space-300);
	}

.filter-btn {
	padding: 8px 16px;
	border: 2px solid var(--color-border);
	border-radius: var(--radius-100);
	background: #ffffff;
	color: var(--color-text);
	font-size: 0.9rem;
	font-weight: 400;
	cursor: pointer;
	transition: all 0.2s ease;
	font-family: inherit;
	}

.filter-btn:hover {
	border-color: var(--color-accent);
	}

.filter-btn.active {
	background: var(--color-accent);
	color: #ffffff;
	border-color: var(--color-accent);
	font-weight: 600;
	}

.filter-btn:focus-visible {
	outline: 3px solid var(--color-focus);
	outline-offset: 0;
	box-shadow: 0 0 0 3px #fd0;
	}

.entry-form {
	background: #f8f8f8;
	border: 1px solid var(--color-border);
	border-radius: var(--radius-100);
	padding: var(--space-300);
	margin-bottom: var(--space-400);
	}

.entry-form h2 {
	margin-top: 0;
	font-size: 1.25rem;
	}

.journal-entries {
	display: flex;
	flex-direction: column;
	gap: var(--space-300);
	}

#entries-container {
	display: flex;
	flex-direction: column;
	gap: 24px;
	}

.entry-card {
	position: relative;
	background: #ffffff;
	border: 1px solid var(--color-border);
	border-left: 4px solid var(--color-accent);
	border-radius: var(--radius-100);
	padding: 24px;
	padding-right: 88px;
	transition: box-shadow 0.2s ease;
	}

.entry-card:hover {
	box-shadow: 0 2px 8px rgba(0,0,0,0.08);
	}

.entry-header {
	display: flex;
	justify-content: space-between;
	align-items: flex-start;
	margin-bottom: 12px;
	gap: 12px;
	}

.entry-meta {
	display: flex;
	flex-direction: column;
	gap: 4px;
	}

.entry-category-badge {
	display: inline-block;
	padding: 4px 10px;
	border-radius: var(--radius-100);
	font-size: 0.85rem;
	font-weight: 600;
	line-height: 1.2;
	white-space: nowrap;
	}

.entry-actions {
	position: absolute;
	top: 12px;
	right: 12px;
	display: inline-flex;
	gap: 8px;
	}

.entry-actions .govuk-button {
	min-width: 0;
	padding: 4px 10px;
	font-size: 14px;
	line-height: 1.2;
	}

.entry-actions .govuk-button--secondary {
	background: #eef5fa;
	color: #0b0c0c;
	border-color: #1d70b8;
	}

.entry-actions .govuk-button--secondary:hover {
	background: #dbe9f4;
	border-color: #003078;
	color: #003078;
	}
	
.entry-actions .govuk-button--edit {
	background: #ffffff;
	color: #1d70b8;
	border-color: #1d70b8;
	}

.entry-content {
	line-height: 1.6;
	white-space: pre-wrap;
	word-wrap: break-word;
	overflow-wrap: break-word;
	display: -webkit-box;
	-webkit-line-clamp: 8;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin-bottom: 8px;
	}

.entry-readmore {
	display: inline-block;
	margin-top: 4px;
	font-size: 14px;
	text-decoration: underline;
	}

.entry-tags {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 8px;
	}

.entry-tags .tag {
	border: 1px solid #b1b4b6;
	background: #ffffff;
	border-radius: 20px;
	padding: 3px 10px;
	font-size: 13px;
	line-height: 1.3;
	cursor: default;
	}

.entry-card[data-category="perceptions"] {
	border-left-color: #1d70b8;
	}

.entry-card[data-category="procedures"] {
	border-left-color: #00703c;
	}

.entry-card[data-category="decisions"] {
	border-left-color: #f47738;
	}

.entry-card[data-category="introspections"] {
	border-left-color: #912b88;
	}

.entry-timestamp {
	font-size: 0.9rem;
	color: var(--color-grey);
	}

.entry-author {
	font-size: 0.85rem;
	color: var(--color-grey);
	}

.empty-journal {
	text-align: center;
	padding: var(--space-400);
	color: var(--color-grey);
	}

.empty-journal-icon {
	font-size: 3rem;
	margin-bottom: var(--space-200);
	opacity: 0.5;
	}

/* === =CODING INTERFACE =================================== */

.selected-text-display {
	background: #fef7e0;
	border: 1px solid #f5c857;
	border-radius: var(--radius-100);
	padding: var(--space-200);
	margin-bottom: var(--space-300);
	font-style: italic;
	}

.coded-segment {
	background-color: var(--code-color, #e8f0fe);
	border-bottom: 2px solid var(--code-color-dark, #1976d2);
	cursor: pointer;
	position: relative;
	}

.coded-segment:hover::after {
	content: attr(data-codes);
	position: absolute;
	bottom: 100%;
	left: 0;
	background: var(--color-text);
	color: #ffffff;
	padding: 4px 8px;
	border-radius: var(--radius-100);
	font-size: 0.75rem;
	white-space: nowrap;
	z-index: 10;
	}

.codebook {
	max-height: 300px;
	overflow-y: auto;
	border: 1px solid var(--color-border);
	border-radius: var(--radius-100);
	padding: var(--space-100);
	}

.code-item {
	padding: var(--space-100);
	cursor: pointer;
	border-radius: var(--radius-100);
	display: flex;
	align-items: center;
	gap: var(--space-100);
	}

.code-item:hover {
	background: #f0f0f0;
	}

.code-item.selected {
	background: var(--color-accent);
	color: #ffffff;
	}

.code-color-indicator {
	width: 12px;
	height: 12px;
	border-radius: 50%;
	flex-shrink: 0;
	}

.analysis-view {
	margin-top: var(--space-400);
	}

.co-occurrence-matrix {
	overflow-x: auto;
	}

.timeline-visualization {
	height: 200px;
	position: relative;
	border: 1px solid var(--color-border);
	border-radius: var(--radius-100);
	}
	
/* === =CODEBOOK TREE ===================================== */

/* space below “Add code” */
#new-code-btn {
	margin-bottom: 1rem;
	}

/* each theme gets colour vars via JS:
   --code-colour, --code-colour-l2, --code-colour-l3 */
.coded-theme {
	margin-bottom: 2rem;
	}

/* top-level theme: either <dl> (no children) or <ul role="group"> (has children) */
.coded-theme dl {
	margin: 0;
	}

/* name bold; description below */
.coded-theme dt.code-name {
	font-weight: 700;
	margin: 0 0 .25rem 0;
	}

.coded-theme dd.code-desc {
	margin: 0 0 .75rem 0;
	font-weight: 400;
	}

/* align dd start under the TEXT inside the chip (not the chip box) */
.coded-theme > dl dd.code-desc,
.coded-theme > ul dd.code-desc { margin-left: 7px; }
.coded-theme > ul ul dd.code-desc { margin-left: 20px; }

/* colour swatch: left rule uses the theme colour variable.
   JS sets --code-colour; we don’t rely on attr() here. */
.colour-swatch {
	padding-left: 8px;
	border-left: 6px solid var(--code-colour, #1d70b8);
	color: var(--code-colour, #1d70b8);
	}

/* path chip */
.path-chip {
	display: inline-block;
	margin-right: 6px;
	padding: 1px 6px;
	font-size: 0.8rem;
	border-radius: 4px;
	background: #f3f2f1;
	color: #505a5f;
	vertical-align: middle;
	}

/* list/tree layout
   - no bullets/indent at theme root
   - bullets only for nested lists, using ↳ (U+21B3)
   - ensure Theme Code 1 aligns with Theme Code 4 (no extra UL padding/margin) */
.coded-theme > ul {
	list-style: none;
	margin: 0;
	padding: 0;
	}

.coded-theme ul {
	margin: 0;
	padding: 0;
	}

/* nested levels: real list bullets with ↳, inside so marker aligns with text */
.coded-theme ul ul {
	list-style-type: '\21B3 ';
	list-style-position: inside;
	padding: 1rem 1.25rem;
	background: color-mix(in srgb, var(--code-colour, #1d70b8) 6%, white);
	}

.coded-theme ul ul ul { padding: 0 1.25rem; }

/* item spacing */
.coded-theme li {
	margin: 0.25rem 0;
	}

/* tint + marker colour by depth (vars provided by JS) */
.coded-theme [role="treeitem"][data-level="2"] {
	color: var(--code-colour-l2, inherit);
	}

.coded-theme [role="treeitem"][data-level="3"] {
	color: var(--code-colour-l3, inherit);
	}

/* keep top-level themes visually distinct */
.coded-theme + .coded-theme {
	border-top: 1px solid #d0d7de;
	padding-top: 1rem;
	}

/* === =CAQDAS INTERFACE =================================== */

.analysis-tabs {
	display: flex;
	gap: 2px;
	margin-bottom: var(--space-400);
	border-bottom: 2px solid var(--color-border);
	}

.analysis-tabs button[role="tab"] {
	padding: 12px 24px;
	background: #f0f0f0;
	border: none;
	border-bottom: 2px solid transparent;
	cursor: pointer;
	font-weight: 400;
	transition: all 0.2s ease;
	}

.analysis-tabs button[role="tab"][aria-selected="true"] {
	background: #ffffff;
	border-bottom-color: var(--color-accent);
	font-weight: 600;
	}

.codeable-text {
	user-select: text;
	position: relative;
	}

::selection {
	background-color: #ffd54f;
	color: #000;
	}

.coding-panel {
	position: fixed;
	right: 0;
	top: 0;
	width: 400px;
	height: 100vh;
	background: #ffffff;
	border-left: 2px solid var(--color-border);
	box-shadow: -2px 0 8px rgba(0,0,0,0.1);
	overflow-y: auto;
	z-index: 1000;
	padding: var(--space-300);
	}

.panel-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: var(--space-300);
	border-bottom: 1px solid var(--color-border);
	}

.selected-text-preview {
	padding: var(--space-300);
	background: #fef7e0;
	border-left: 4px solid #f5c857;
	margin: var(--space-300);
	}

.selected-text-preview blockquote {
	margin: 8px 0 0;
	font-style: italic;
	}

.color-field {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	flex-wrap: nowrap;
	}

.color-field__input {
	width: 100%;
	max-width: 100%;
	font-family: ui-monospace, 'Monaco', monospace;
	text-transform: lowercase;
	}

.clr-field {
	display: flex;
	align-items: center;
	}

.clr-field button {
	margin-left: 8px;
	}

.clr-picker {
	border-radius: 4px !important;
	box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
	}

.clr-picker button {
	border-radius: 4px !important;
	}

.clr-field input:focus {
	outline: 3px solid #fd0;
	outline-offset: 0;
	box-shadow: 0 0 0 3px #0b0c0c;
	}

.codebook-tree {
	max-height: 300px;
	overflow-y: auto;
	border: 1px solid var(--color-border);
	margin: var(--space-300);
	}

.code-item[aria-level="2"] {
	padding-left: 28px;
	}

.code-item[aria-level="3"] {
	padding-left: 44px;
	}

.coding-confidence fieldset {
	border: 1px solid var(--color-border);
	padding: var(--space-200);
	margin: var(--space-300);
	}

.coding-confidence label {
	display: inline-block;
	margin-right: var(--space-200);
	}

.analysis-options {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
	gap: var(--space-300);
	margin-bottom: var(--space-400);
	}

.analysis-btn {
	padding: var(--space-300);
	text-align: center;
	background: #ffffff;
	border: 2px solid var(--color-border);
	border-radius: var(--radius-100);
	cursor: pointer;
	transition: all 0.2s ease;
	}

.analysis-btn:hover {
	border-color: var(--color-accent);
	box-shadow: 0 2px 4px rgba(0,0,0,0.1);
	}

.memo-card {
	background: #f8f9fa;
	border: 1px solid var(--color-border);
	border-radius: var(--radius-100);
	padding: var(--space-300);
	margin-bottom: var(--space-300);
	}

.memo-type-badge {
	display: inline-block;
	padding: 4px 12px;
	border-radius: var(--radius-100);
	font-size: 0.85rem;
	font-weight: 600;
	}

.memo-type-badge[data-type="analytical"] {
	background: #e3f2fd;
	color: #1976d2;
	}

.memo-type-badge[data-type="methodological"] {
	background: #f3e5f5;
	color: #7b1fa2;
	}

.memo-type-badge[data-type="theoretical"] {
	background: #fff3e0;
	color: #f57c00;
	}

.memo-type-badge[data-type="reflexive"] {
	background: #e8f5e9;
	color: #388e3c;
	}

/* === =RESPONSIVE (Journal) ============================== */

@media (max-width: 640px) {
	.journal-header {
		flex-direction: column;
		align-items: flex-start;
		}

	.filter-group {
		width: 100%;
		}

	.filter-btn {
		flex: 1;
		min-width: 0;
		font-size: 0.85rem;
		padding: 6px 12px;
		}

	.entry-header {
		flex-direction: column;
		}

	.entry-category-badge {
		align-self: flex-start;
		}
	}

@media (prefers-reduced-motion: reduce) {
	.filter-btn,
	.entry-card {
		transition: none;
		}
	}

/* transparency begins in the cascade */
