/* Fount Programme Builder — public planning page */

:root {
	--ink: #0b494f;
	--ink-2: #3d6266;
	--muted: #6f8487;
	--accent: #07939a;
	--accent-ink: #056f75;
	--accent-soft: #e3f1f2;
	--paper: #f7f5f0;
	--card: #ffffff;
	--line: #e3e0d8;
	--line-strong: #cfcbc0;
	--warn: #b25e00;
	--danger: #b3261e;
	--ok: #1f7a4d;
	--radius: 12px;
	--shadow: 0 1px 2px rgba(11, 73, 79, .06), 0 4px 16px rgba(11, 73, 79, .05);
	--serif: "Cinzel", "Trajan Pro", Georgia, serif;
	--sans: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
	margin: 0; background: var(--paper); color: var(--ink);
	font: 400 15px/1.5 var(--sans);
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2 { margin: 0; font-weight: 600; }

/* ------------------------------------------------------------- buttons */
.btn {
	display: inline-flex; align-items: center; justify-content: center; gap: 6px;
	min-height: 42px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
	font-weight: 500; font-size: 14px; cursor: pointer; text-decoration: none;
	transition: background .15s, border-color .15s, box-shadow .15s, transform .05s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: progress; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #083a3f; }
.btn-soft { background: var(--accent-soft); color: var(--accent-ink); }
.btn-soft:hover { background: #d3e9eb; }
.btn-ghost { background: transparent; border-color: var(--line-strong); color: var(--ink-2); }
.btn-ghost:hover { border-color: var(--accent); color: var(--ink); }
.btn-block { width: 100%; }
.icon-btn {
	width: 36px; height: 36px; border: 0; border-radius: 8px; background: transparent;
	font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer;
}
.icon-btn:hover { background: var(--accent-soft); color: var(--ink); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ------------------------------------------------------------- loading */
.loading { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; color: var(--muted); font-size: 14px; }
.spinner { width: 28px; height: 28px; border-radius: 50%; border: 3px solid var(--accent-soft); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* ---------------------------------------------------------------- gate */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.gate-card {
	width: min(400px, 100%); padding: 36px 32px; background: var(--card);
	border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); text-align: center;
}
.gate-logo { width: 150px; margin-bottom: 18px; }
.gate-card h1 { font-family: var(--serif); font-size: 24px; letter-spacing: .02em; }
.gate-card > p { color: var(--ink-2); margin: 6px 0 22px; }
.gate-card .field { text-align: left; }
.gate-error { color: var(--danger); font-size: 14px; margin: -6px 0 12px; }
.gate-note { font-size: 13px; color: var(--muted); margin: 14px 0 0; }

/* -------------------------------------------------------------- layout */
.topbar {
	position: sticky; top: 0; z-index: 20;
	display: flex; align-items: center; justify-content: space-between; gap: 12px;
	padding: 12px 24px; background: rgba(247, 245, 240, .92);
	backdrop-filter: blur(8px); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand img { height: 40px; width: auto; }
.brand > div { display: flex; flex-direction: column; border-left: 1px solid var(--line-strong); padding-left: 14px; }
.brand-title { font-family: var(--serif); font-weight: 600; font-size: 17px; letter-spacing: .02em; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--muted); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.save-state { font-size: 13px; color: var(--muted); white-space: nowrap; }
.save-state.dirty { color: var(--warn); }
.save-state.saved { color: var(--ok); }

.layout {
	display: grid; grid-template-columns: 260px minmax(0, 1fr) 300px; gap: 28px;
	max-width: 1360px; margin: 0 auto; padding: 28px 24px 64px; align-items: start;
}

/* ------------------------------------------------------------- sidebar */
.sidebar { position: sticky; top: 92px; display: flex; flex-direction: column; gap: 10px; max-height: calc(100vh - 110px); }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; }
.sidebar h2, .panel h2 { font-family: var(--serif); font-size: 15px; letter-spacing: .06em; text-transform: uppercase; }
.programme-list { list-style: none; margin: 8px 0 0; padding: 0; overflow-y: auto; flex: 1; }
.programme-list li + li { margin-top: 2px; }
.programme-list button {
	width: 100%; text-align: left; padding: 10px 12px; border: 0; border-radius: 10px;
	background: transparent; cursor: pointer; display: grid; gap: 1px;
}
.programme-list button:hover { background: rgba(7, 147, 154, .07); }
.programme-list button.active { background: var(--card); box-shadow: var(--shadow); }
.programme-list .p-date { font-weight: 600; font-size: 14px; }
.programme-list .p-meta { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.programme-list .badge {
	justify-self: start; margin-top: 3px; padding: 1px 8px; border-radius: 999px;
	font-size: 11px; font-weight: 500; background: #efe9dc; color: #7a6a45;
}
.list-empty { color: var(--muted); font-size: 13px; padding: 8px 12px; }

/* -------------------------------------------------------------- editor */
.editor-head { margin: 2px 0 20px; }
.eyebrow { margin: 0 0 4px; font-size: 12px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--accent-ink); }
.editor-head h1 { font-family: var(--serif); font-size: clamp(24px, 3vw, 32px); letter-spacing: .01em; line-height: 1.2; }

.card {
	background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
	box-shadow: var(--shadow); padding: 22px 24px 8px; margin-bottom: 18px;
	scroll-margin-top: 90px;
}
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.card-head h2 { font-family: var(--serif); font-size: 18px; letter-spacing: .02em; }
.num {
	display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%;
	background: var(--accent-soft); color: var(--accent-ink); font-size: 13px; font-weight: 600;
}
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }

.field { display: block; margin-bottom: 16px; }
.field-label { display: block; margin-bottom: 6px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
.hint { font-weight: 400; color: var(--muted); margin-left: 6px; }
.field input[type=text], .field input[type=date], .field input[type=password], .field textarea, .field select, .combo-input {
	width: 100%; min-height: 44px; padding: 10px 14px; border: 1px solid var(--line-strong); border-radius: 10px;
	background: #fff; transition: border-color .15s, box-shadow .15s;
}
.field textarea { resize: vertical; line-height: 1.5; }
.field input:focus, .field textarea:focus, .field select:focus, .combo-input:focus {
	outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(7, 147, 154, .15);
}
.field input.invalid { border-color: var(--danger); box-shadow: 0 0 0 3px rgba(179, 38, 30, .12); }
::placeholder { color: #a7b3b4; opacity: 1; }
.rte-body:empty::before { content: "Type this week's announcements…"; color: #a7b3b4; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; }

/* combobox */
.combo { position: relative; }
.combo-wrap { position: relative; }
.combo-input { padding-right: 40px; }
.combo-clear {
	position: absolute; right: 6px; top: 6px; width: 32px; height: 32px; border: 0; border-radius: 8px;
	background: transparent; color: var(--muted); font-size: 18px; cursor: pointer;
}
.combo-clear:hover { background: var(--accent-soft); color: var(--ink); }
.combo-list {
	position: absolute; z-index: 30; left: 0; right: 0; top: calc(100% + 4px);
	max-height: 300px; overflow-y: auto; margin: 0; padding: 6px; list-style: none;
	background: #fff; border: 1px solid var(--line-strong); border-radius: 12px;
	box-shadow: 0 12px 32px rgba(11, 73, 79, .16);
}
.combo-list li { padding: 9px 12px; border-radius: 8px; cursor: pointer; }
.combo-list li.active, .combo-list li:hover { background: var(--accent-soft); }
.combo-list .t { display: block; font-weight: 500; }
.combo-list .m { display: block; font-size: 12px; color: var(--muted); }
.combo-list li.add { color: var(--accent-ink); font-weight: 500; border-top: 1px solid var(--line); border-radius: 0 0 8px 8px; margin-top: 4px; }
.combo-list li.empty { color: var(--muted); cursor: default; }
.combo-list li.empty:hover { background: none; }
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.combo-list li.other .m { color: var(--accent-ink); }
.combo-list li.add { position: sticky; bottom: -6px; background: #fff; }
.combo-list li.add.active, .combo-list li.add:hover { background: var(--accent-soft); }
.link-btn { padding: 0; border: 0; background: none; color: var(--accent-ink); font-size: 12.5px; font-weight: 500; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }

/* multi rows */
.multi-row { display: grid; grid-template-columns: 26px minmax(0, 1fr) auto; gap: 8px; align-items: start; margin-bottom: 10px; }
.multi-row .order { display: flex; flex-direction: column; padding-top: 4px; }
.multi-row .order button { height: 18px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 11px; line-height: 1; }
.multi-row .order button:hover { color: var(--ink); }
.multi-row .order button:disabled { visibility: hidden; }
.multi-row .remove { height: 44px; padding: 0 10px; border: 0; background: none; color: var(--muted); cursor: pointer; font-size: 13px; }
.multi-row .remove:hover { color: var(--danger); }
.add-row { margin: 0 0 16px 34px; min-height: 36px; padding: 0 14px; font-size: 13px; }

/* rich text */
.rte { border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; margin-bottom: 16px; background: #fff; }
.rte:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(7, 147, 154, .15); }
.rte-bar { display: flex; gap: 4px; padding: 6px; border-bottom: 1px solid var(--line); background: #fbfaf7; }
.rte-bar button { min-width: 34px; height: 32px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; color: var(--ink-2); }
.rte-bar button:hover { background: var(--accent-soft); color: var(--ink); }
.rte-bar .rte-reset { margin-left: auto; font-size: 12.5px; padding: 0 10px; color: var(--muted); }
.rte-body { min-height: 180px; padding: 14px 16px; outline: none; text-align: center; font-size: 14px; }
.rte-body h4 { margin: 0; font-weight: 600; font-size: 14.5px; }
.rte-body p { margin: 0 0 12px; }

/* ---------------------------------------------------------------- panel */
.panel { position: sticky; top: 92px; min-width: 0; }
.panel-inner { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; display: grid; gap: 10px; }
.panel-sub { margin: -6px 0 4px; font-size: 13px; color: var(--muted); }
.pages { list-style: none; margin: 0 0 8px; padding: 0; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
.pages li {
	position: relative; aspect-ratio: 148 / 210; border-radius: 4px; border: 1px solid var(--line-strong);
	background: #fff; padding: 5px 4px; font-size: 9.5px; line-height: 1.15; color: var(--muted);
	display: flex; flex-direction: column; justify-content: space-between; cursor: pointer;
	transition: border-color .15s, transform .15s;
}
.pages li:hover { border-color: var(--accent); transform: translateY(-1px); }
.pages li .pn { font-family: var(--serif); font-size: 10px; color: var(--ink-2); }
.pages li .pl { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pages li::after { content: ""; position: absolute; top: 5px; right: 5px; width: 7px; height: 7px; border-radius: 50%; background: var(--line-strong); }
.pages li.done { border-color: rgba(7, 147, 154, .45); background: linear-gradient(#fff, #f2f9f9); color: var(--ink); }
.pages li.done::after { background: var(--accent); }
.pages li.extra { border-style: dashed; }
.panel-note { margin: 4px 0 0; font-size: 12.5px; color: var(--muted); word-break: break-word; }
.panel-note a { color: var(--accent-ink); }

/* ------------------------------------------------- verse, layout, share */
.input-action { display: flex; gap: 8px; }
.input-action input { flex: 1; min-width: 0; }
.input-action .btn { flex: none; min-height: 44px; padding: 0 14px; }
.pages li.overflow { border-color: var(--danger); background: #fdf1f0; }
.pages li.overflow::after { background: var(--danger); }
.layout-warn { margin: -2px 0 6px; padding: 10px 12px; border-radius: 10px; background: #fdf1f0; color: #8c1d18; font-size: 13px; line-height: 1.45; }
.layout-warn em { color: var(--muted); font-style: normal; }
.layout-warn.checking { background: var(--accent-soft); color: var(--accent-ink); }
.share { position: relative; }
.share-menu {
	position: absolute; z-index: 25; left: 0; right: 0; bottom: calc(100% + 6px);
	padding: 6px; background: #fff; border: 1px solid var(--line-strong); border-radius: 12px;
	box-shadow: 0 12px 32px rgba(11, 73, 79, .16);
}
.share-menu button { display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: 8px; background: none; text-align: left; font-weight: 500; cursor: pointer; }
.share-menu button:hover { background: var(--accent-soft); }
.share-menu p { margin: 4px 12px 6px; font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- modal */
.modal { border: 0; padding: 0; background: transparent; width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 32px); }
.modal::backdrop { background: rgba(11, 40, 43, .45); backdrop-filter: blur(2px); }
.modal-card { background: var(--card); border-radius: 16px; padding: 22px 24px; box-shadow: 0 24px 64px rgba(0, 0, 0, .25); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h2 { font-family: var(--serif); font-size: 20px; }
.modal textarea { font-size: 14px; }
.check { display: flex; gap: 8px; align-items: center; font-size: 14px; margin-bottom: 8px; }
.modal-note { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }
.form-error { color: var(--danger); font-size: 14px; }
.dupe { margin: 6px 0 4px; padding: 12px 14px; border-radius: 10px; background: #fbf3e4; color: #6b4507; font-size: 13.5px; }
.dupe p { margin: 0 0 10px; }
.dupe-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dupe-actions .btn { min-height: 38px; padding: 0 14px; font-size: 13px; }
.modal-small { width: min(460px, calc(100vw - 24px)); }
.roles { border: 0; margin: 0 0 8px; padding: 0; }
.roles .check { margin: 6px 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* --------------------------------------------------------- sunday type */
.type-switch { display: inline-flex; margin-top: 14px; padding: 4px; gap: 4px; border-radius: 12px; background: #ece8df; }
.type-switch label { cursor: pointer; }
.type-switch input { position: absolute; opacity: 0; }
.type-switch span {
	display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border-radius: 9px;
	font-size: 13.5px; font-weight: 500; color: var(--ink-2); transition: background .15s, color .15s, box-shadow .15s;
}
.type-switch svg, .supper-title svg, .type-icon svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.type-switch input:checked + span { background: var(--card); color: var(--ink); box-shadow: 0 1px 3px rgba(11, 73, 79, .15); }
.type-switch input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.supper-block { margin: 4px -10px 16px; padding: 14px 10px 2px; border-radius: 10px; background: #f3f8f8; border: 1px dashed rgba(7, 147, 154, .4); }
.supper-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-family: var(--serif); font-weight: 600; color: var(--accent-ink); }

.type-copy { margin: -4px 0 14px; padding: 10px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent-ink); font-size: 13.5px; }
.type-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 6px; }
.type-card {
	position: relative; display: grid; gap: 6px; justify-items: start; text-align: left;
	padding: 18px 16px 16px; border: 1.5px solid var(--line-strong); border-radius: 14px; background: #fff; cursor: pointer;
	transition: border-color .15s, box-shadow .15s, transform .1s;
}
.type-card:hover { border-color: var(--accent); box-shadow: 0 6px 18px rgba(7, 147, 154, .14); transform: translateY(-1px); }
.type-card.suggested { border-color: var(--accent); background: linear-gradient(#fff, #f3f9f9); }
.type-card strong { font-family: var(--serif); font-size: 17px; font-weight: 600; color: var(--ink); }
.type-card > span:not(.type-icon) { font-size: 13px; color: var(--ink-2); line-height: 1.45; }
.type-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--accent-soft); color: var(--accent-ink); }
.type-icon svg { width: 22px; height: 22px; }
.suggest { position: absolute; top: 12px; right: 12px; padding: 2px 9px; border-radius: 999px; background: var(--accent); color: #fff; font-size: 11px; font-style: normal; font-weight: 600; }
.type-why { min-height: 1.4em; margin: 12px 0 0; font-size: 13px; color: var(--muted); }
.programme-list .badge.communion { background: #f4ecdf; color: #8a5a1c; }
.badges { display: flex; gap: 4px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- toast */
.toast {
	position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50;
	max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 10px;
	background: var(--ink); color: #fff; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, .2);
}
.toast.error { background: var(--danger); }

.mobile-bar, .only-mobile { display: none; }

/* ----------------------------------------------------------- responsive */
@media (max-width: 1180px) {
	.layout { grid-template-columns: 230px minmax(0, 1fr); }
	.panel { grid-column: 2; position: static; }
}
@media (max-width: 860px) {
	.topbar { padding: 10px 16px; }
	.brand img { height: 32px; }
	.brand-sub { display: none; }
	.only-mobile { display: inline-flex; }
	.layout { display: block; padding: 18px 16px 110px; }
	.sidebar {
		position: fixed; inset: 0 auto 0 0; z-index: 40; width: min(320px, 86vw); max-height: none;
		padding: 18px 16px; background: var(--paper); box-shadow: 8px 0 32px rgba(0, 0, 0, .18);
		transform: translateX(-105%); transition: transform .2s;
	}
	.sidebar.open { transform: none; }
	.card { padding: 18px 16px 4px; }
	.grid-2 { grid-template-columns: 1fr; }
	.type-choices { grid-template-columns: 1fr; }
	.type-switch { display: flex; }
	.type-switch label { flex: 1; }
	.type-switch span { width: 100%; justify-content: center; padding: 8px 6px; }
	.panel { margin-top: 8px; }
	.pages { grid-template-columns: repeat(6, minmax(0, 1fr)); }
	.panel #save-btn, .panel #preview-btn { display: none; }
	.mobile-bar {
		display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
		position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
		padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
		background: rgba(247, 245, 240, .96); border-top: 1px solid var(--line); backdrop-filter: blur(8px);
	}
	.save-state { font-size: 12px; }
	/* 16px stops iPhone Safari zooming in when a field is tapped */
	.field input, .field textarea, .field select, .combo-input, .rte-body { font-size: 16px; }
	.toast { bottom: 84px; }
}
@media (max-width: 480px) {
	.pages { grid-template-columns: repeat(4, minmax(0, 1fr)); }
	.brand > div { padding-left: 10px; }
	.brand-title { font-size: 15px; }
}
