/* GES Templates engine — catalog + split-screen editor.
   Aligns with the theme (Geneva red, Schibsted/Hanken via theme.json vars). */
.ges-tpl { --r: #e8423f; --ink: #1a1a1a; --bd: #e3e5e9; --muted: #44474d; --ease: cubic-bezier(.16,.84,.24,1); color: var(--ink); }
.ges-tpl * { box-sizing: border-box; }
.ges-tpl__loading { padding: 4rem 1rem; text-align: center; color: var(--muted); }

/* shared bits */
.ges-tpl h2 { font-family: var(--wp--preset--font-family--heading, inherit); letter-spacing: -0.02em; }
.ges-tpl .btn { display: inline-flex; align-items: center; gap: .5rem; font: inherit; font-weight: 700; border: 0; border-radius: 11px; padding: .8rem 1.4rem; cursor: pointer; text-decoration: none; min-height: 3rem; transition: transform .18s var(--ease), background .18s var(--ease); }
.ges-tpl .btn:hover { transform: translateY(-2px); }
.ges-tpl .btn--primary { background: var(--r); color: #fff; box-shadow: 0 8px 20px rgba(200,51,47,.22); }
.ges-tpl .btn--ghost { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px rgba(20,22,26,.2); }
.ges-tpl .btn--sm { padding: .55rem .9rem; min-height: 0; font-size: .9rem; border-radius: 9px; }
.ges-tpl .muted { color: var(--muted); }
.ges-tpl .tag { font-size: .72rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; color: var(--r); }

/* tabs / header */
.ges-tpl__bar { display: flex; flex-wrap: wrap; gap: 1rem; align-items: center; justify-content: space-between; margin-bottom: 1.75rem; }
.ges-tpl__tabs { display: flex; gap: .25rem; background: #f3f4f6; padding: .25rem; border-radius: 12px; }
.ges-tpl__tabs button { font: inherit; font-weight: 600; border: 0; background: transparent; padding: .55rem 1rem; border-radius: 9px; cursor: pointer; color: var(--muted); }
.ges-tpl__tabs button[aria-selected="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }

/* catalog */
.ges-tpl__grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1.25rem; }
.ges-tpl__card { display: flex; flex-direction: column; border: 1px solid var(--bd); border-radius: 16px; background: #fff; padding: 1.4rem; box-shadow: 0 1px 2px rgba(20,22,26,.04), 0 6px 16px rgba(20,22,26,.05); transition: transform .2s var(--ease), box-shadow .2s var(--ease); }
.ges-tpl__card:hover { transform: translateY(-4px); box-shadow: 0 14px 34px rgba(20,22,26,.10); }
.ges-tpl__card h3 { margin: .5rem 0 .4rem; font-size: 1.18rem; letter-spacing: -0.01em; font-family: var(--wp--preset--font-family--heading, inherit); }
.ges-tpl__card p { margin: 0 0 1.1rem; color: #34373d; font-size: .95rem; flex: 1; }
.ges-tpl__cardfoot { display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.ges-tpl__price { font-weight: 800; font-family: var(--wp--preset--font-family--heading, inherit); }
.ges-tpl__owned { font-size: .78rem; font-weight: 700; color: #1a7f37; background: #e7f6ec; padding: .2rem .55rem; border-radius: 999px; }

/* editor — fields stacked on top, A4 render below (room for the big text areas) */
.ges-ed { display: grid; grid-template-columns: 1fr; gap: 1.75rem; }
.ges-ed__panel { position: static; }
.ges-ed__form { background: #fff; border: 1px solid var(--bd); border-radius: 18px; padding: clamp(1.25rem, 2.5vw, 1.9rem); }
/* two fields per row; the letter body spans the full width */
.ges-ed__form form { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem 1.25rem; align-items: start; }
.ges-ed__form .field { margin-bottom: 0; }
.ges-ed__form .field:has(#f-body) { grid-column: 1 / -1; }
.ges-ed__form label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }
.ges-ed__form input, .ges-ed__form textarea { box-sizing: border-box; width: 100%; padding: .8rem 1rem; border: 1.5px solid var(--bd); border-radius: 11px; font: inherit; background: #fcfcfd; min-height: 3rem; }
.ges-ed__form textarea { min-height: 5rem; resize: vertical; line-height: 1.55; overflow: hidden; }
.ges-ed__form #f-body { min-height: 13rem; }
.ges-ed__form input:focus, .ges-ed__form textarea:focus { outline: none; border-color: var(--r); box-shadow: 0 0 0 3px rgba(232,66,63,.14); }

.ges-ed__toolbar { display: flex; flex-wrap: wrap; gap: .6rem 1rem; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.ges-ed__modes { display: inline-flex; background: #f3f4f6; border-radius: 11px; padding: .25rem; gap: .2rem; }
.ges-ed__modes label { display: inline-flex; align-items: center; gap: .4rem; padding: .5rem .85rem; border-radius: 9px; font-size: .9rem; font-weight: 600; cursor: pointer; color: var(--muted); }
.ges-ed__modes input { position: absolute; opacity: 0; pointer-events: none; }
.ges-ed__modes label:has(input:checked) { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.ges-ed__hint { font-size: .85rem; }

/* A4 live preview */
.ges-ed__previewwrap { background: #eceef1; border-radius: 18px; padding: 1.25rem; max-height: 80vh; overflow: auto; }
.ges-a4 { width: 794px; max-width: 100%; min-height: 1123px; margin: 0 auto; background: #fff; box-shadow: 0 8px 30px rgba(20,22,26,.14); padding: 96px 85px; font-family: "Times New Roman", Georgia, serif; color: #111; font-size: 15px; line-height: 1.55; }
.ges-a4 .doc-head, .ges-a4 .doc-foot { color: #555; font-size: 11.5px; }
.ges-a4 .doc-foot { margin-top: 56px; border-top: 1px solid #ddd; padding-top: 8px; }
.ges-a4 .sender { margin-bottom: 36px; }
.ges-a4 .recipient { margin: 0 0 28px auto; width: 60%; }
.ges-a4 .placedate { text-align: right; margin-bottom: 28px; }
.ges-a4 .subject { font-weight: 700; margin-bottom: 22px; }
.ges-a4 .body { white-space: pre-wrap; }
.ges-a4 .sign { margin-top: 40px; }
.ges-a4 .ph { color: #b9bcc2; }

/* Paged.js live pages */
.ges-pages { width: 100%; }
.ges-pages .pagedjs_pages { display: flex; flex-direction: column; align-items: center; gap: 1.1rem; }
.ges-pages .pagedjs_page { background: #fff; box-shadow: 0 8px 30px rgba(20,22,26,.16); }
.ges-pages .pagedjs_margin-content { font-family: "Hanken Grotesk", system-ui, sans-serif; }

@media (max-width: 860px) {
	.ges-ed { grid-template-columns: 1fr; }
	.ges-ed__panel { position: static; }
	.ges-a4 { padding: 56px 44px; min-height: 0; }
}

@media (max-width: 640px) {
	.ges-ed__form form { grid-template-columns: 1fr; } /* one field per row on phones */
}

/* purchase / gate */
.ges-tpl__gate { max-width: 520px; margin: 2rem auto; text-align: center; background: #fff; border: 1px solid var(--bd); border-radius: 20px; padding: 2.5rem; box-shadow: 0 14px 40px rgba(20,22,26,.08); }
.ges-tpl__gate .big { font-size: 2rem; font-weight: 800; font-family: var(--wp--preset--font-family--heading, inherit); margin: .5rem 0; }
.ges-tpl__field { margin: 1rem 0; text-align: left; }
.ges-tpl__field input { width: 100%; padding: .8rem 1rem; border: 1.5px solid var(--bd); border-radius: 11px; font: inherit; min-height: 3rem; }

.ges-tpl__docs { display: grid; gap: .75rem; }
.ges-tpl__doc { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border: 1px solid var(--bd); border-radius: 14px; background: #fff; }

.ges-tpl__toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .8rem 1.25rem; border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 9999; font-weight: 600; }

/* PRINT — WYSIWYG: print the Paged.js pages exactly as previewed (Chrome save-as-PDF) */
@media print {
	@page { size: A4; margin: 0; }
	body * { visibility: hidden !important; }
	#ed-pages, #ed-pages * { visibility: visible !important; }
	#ed-pages { position: absolute; left: 0; top: 0; zoom: 1 !important; }
	#ed-pages .pagedjs_pages { display: block !important; gap: 0 !important; }
	#ed-pages .pagedjs_page { box-shadow: none !important; margin: 0 !important; break-after: page; }
}
