/* படக் கவிதை — image poems: the write-form designer, feed cards, gallery and
   reading page. Colours come from the theme tokens, so dark mode follows. */

/* Write form: text / image switch */
.kk-format-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 18px 0 4px; }
.kk-format-opt { position: relative; cursor: pointer; }
.kk-format-opt input { position: absolute; opacity: 0; pointer-events: none; }
.kk-format-opt span {
	display: flex; flex-direction: column; gap: 2px; height: 100%;
	padding: 12px 14px; border-radius: var(--kk-radius-sm);
	background: var(--kk-surface-2); border: 1.5px solid var(--kk-line-2);
	transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.kk-format-opt b { font-size: 15px; color: var(--kk-ink); }
.kk-format-opt small { font-size: 12px; color: var(--kk-muted); }
.kk-format-opt input:checked + span { border-color: var(--kk-green); background: var(--kk-surface); box-shadow: var(--kk-shadow-1); }
.kk-format-opt input:focus-visible + span { outline: 2px solid var(--kk-green); outline-offset: 2px; }

/* Designer */
.kk-imgpoem { display: none; }
#kk-write-form.is-image .kk-imgpoem {
	display: grid; grid-template-columns: minmax(0, 380px) minmax(0, 1fr); gap: 22px; align-items: start;
	margin-top: 16px; padding: 18px; border-radius: var(--kk-radius);
	background: var(--kk-surface-2); border: 1px solid var(--kk-line);
}
.kk-imgpoem-stage { position: sticky; top: 84px; }
.kk-imgpoem-canvas {
	display: block; width: 100%; height: auto; aspect-ratio: 4 / 5;
	border-radius: 12px; box-shadow: var(--kk-shadow-2); background: #222;
	touch-action: none; cursor: grab;
}
.kk-imgpoem-canvas:active { cursor: grabbing; }
.kk-imgpoem-warn { margin: 10px 0 0; padding: 8px 12px; border-radius: 8px; font-size: 13px; background: #fdecea; color: #a12b1f; }
.kk-imgpoem-tip { margin: 8px 0 0; font-size: 12.5px; color: var(--kk-muted); text-align: center; }
.kk-imgpoem-tools { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.kk-imgpoem-row { display: flex; gap: 18px; flex-wrap: wrap; }
.kk-imgpoem-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.kk-imgpoem-group > .kk-label { margin: 0; }

.kk-imgpoem-swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 8px; }
.kk-imgpoem-swatch,
.kk-imgpoem-upload > span {
	position: relative; display: flex; align-items: flex-end; justify-content: center;
	aspect-ratio: 4 / 5; border-radius: 9px; border: 2px solid transparent;
	padding: 0 2px 5px; cursor: pointer; overflow: hidden;
	font: 600 11px/1.2 var(--kk-ui); color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .6);
	box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .08);
	transition: transform .15s ease, border-color .15s ease;
}
.kk-imgpoem-swatch:hover,
.kk-imgpoem-upload:hover > span { transform: translateY(-2px); }
.kk-imgpoem-swatch[aria-pressed="true"],
.kk-imgpoem-upload.is-on > span { border-color: var(--kk-green); box-shadow: 0 0 0 2px var(--kk-surface), 0 0 0 4px var(--kk-green); }
.kk-imgpoem-upload { position: relative; display: block; }
.kk-imgpoem-upload input { position: absolute; inset: 0; opacity: 0; cursor: pointer; z-index: 1; }
.kk-imgpoem-upload > span {
	flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 22px;
	background: var(--kk-surface); color: var(--kk-ink-2); text-shadow: none; border: 2px dashed var(--kk-line-2);
}
.kk-imgpoem-upload small { font: 600 11px var(--kk-ui); }
.kk-imgpoem-swatch--dawn   { background: linear-gradient(160deg, #ffe2b8, #f7b2a4, #d49bc0); color: #3b2316; text-shadow: none; }
.kk-imgpoem-swatch--sunset { background: linear-gradient(160deg, #ffb26b, #ef6a6a, #5d2e73); }
.kk-imgpoem-swatch--night  { background: radial-gradient(circle at 30% 25%, #fff 0 1px, transparent 2px), radial-gradient(circle at 70% 40%, #fff 0 1px, transparent 2px), linear-gradient(160deg, #0a1433, #18295a, #33285e); }
.kk-imgpoem-swatch--moon   { background: radial-gradient(circle at 72% 20%, #f6e7b8 0 9px, transparent 10px), linear-gradient(160deg, #0d111d, #1d2540); }
.kk-imgpoem-swatch--sea    { background: linear-gradient(160deg, #38a3c4, #1d5f8a, #0b2a4a); }
.kk-imgpoem-swatch--leaf   { background: linear-gradient(160deg, #dcefc2, #86b85f, #2f5d2a); }
.kk-imgpoem-swatch--paper  { background: linear-gradient(160deg, #fcf6e7, #efe1c2); color: #2b2115; text-shadow: none; }
.kk-imgpoem-swatch--ink    { background: linear-gradient(160deg, #161616, #2a2622); }
.kk-imgpoem-swatch--rain   { background: repeating-linear-gradient(105deg, rgba(255, 255, 255, .12) 0 1px, transparent 1px 9px), linear-gradient(160deg, #6b7b8c, #3c4f63, #1f2d3a); }
.kk-imgpoem-swatch--rose   { background: linear-gradient(160deg, #ffe4e8, #f8b9c6, #e58aa6); color: #4a1d2e; text-shadow: none; }
.kk-imgpoem-swatch--gold   { background: linear-gradient(160deg, #2e2009, #6d4f17, #c39a4b); }
.kk-imgpoem-swatch--clay   { background: linear-gradient(160deg, #f0d2b0, #c9845c, #7d3f25); }

.kk-imgpoem-seg { display: inline-flex; flex-wrap: wrap; gap: 6px; }
.kk-imgpoem-seg button {
	display: inline-flex; align-items: center; gap: 6px; min-height: 36px; min-width: 40px; padding: 0 12px;
	border-radius: 999px; border: 1px solid var(--kk-line-2); background: var(--kk-surface);
	font: 600 13px var(--kk-ui); color: var(--kk-ink-2); cursor: pointer;
	transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.kk-imgpoem-seg button:hover { border-color: var(--kk-gold-soft); }
.kk-imgpoem-seg button[aria-pressed="true"] { background: var(--kk-green); border-color: var(--kk-green); color: var(--kk-on-green); }
.kk-imgpoem-seg button:focus-visible,
.kk-imgpoem-swatch:focus-visible { outline: 2px solid var(--kk-green); outline-offset: 2px; }
.kk-dot { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .25); }
.kk-imgpoem-range { flex: 1 1 180px; }
.kk-imgpoem-range input { width: 100%; accent-color: var(--kk-green); }
.kk-imgpoem-check,
.kk-imgpoem-rights { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; color: var(--kk-ink-2); cursor: pointer; }
.kk-imgpoem-check input,
.kk-imgpoem-rights input { margin-top: 3px; accent-color: var(--kk-green); flex: none; }
.kk-imgpoem-rights { margin-top: 10px; padding: 10px 12px; border-radius: 8px; background: var(--kk-surface); border: 1px dashed var(--kk-gold-soft); line-height: 1.5; }
.kk-imgpoem [hidden] { display: none !important; }

@media (max-width: 760px) {
	#kk-write-form.is-image .kk-imgpoem { grid-template-columns: 1fr; padding: 12px; }
	.kk-imgpoem-stage { position: static; max-width: 420px; margin: 0 auto; width: 100%; }
	.kk-imgpoem-swatches { grid-template-columns: repeat(5, 1fr); }
}

/* Feed card */
.kk-poem-card--image { padding: 0; gap: 0; }
.kk-poem-card--image .kk-poem-card-top { padding: 14px 16px 10px; }
.kk-imgpoem-figure { display: block; margin: 0; background: var(--kk-surface-2); aspect-ratio: 4 / 5; overflow: hidden; }
.kk-imgpoem-figure img,
.kk-imgpoem-img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .5s var(--kk-ease); }
.kk-poem-card--image:hover .kk-imgpoem-figure img { transform: scale(1.025); }
.kk-poem-card--image .kk-poem-title { padding: 12px 16px 0; font-size: 16px; }
.kk-poem-card--image .kk-poem-card-foot { padding: 10px 16px 14px; }
.kk-grid--featured > .kk-poem-card--image:first-child { grid-column: auto; }

/* Gallery view (?view=images): denser grid, pictures first */
.kk-grid--gallery { grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
@media (max-width: 560px) {
	.kk-grid--gallery { grid-template-columns: 1fr 1fr; gap: 10px; }
	.kk-grid--gallery .kk-poem-card--image .kk-poem-card-top { display: none; }
	.kk-grid--gallery .kk-poem-card--image .kk-poem-title { font-size: 13.5px; padding: 8px 10px 0; }
	.kk-grid--gallery .kk-poem-card--image .kk-poem-card-foot { padding: 6px 10px 10px; flex-wrap: wrap; }
	.kk-grid--gallery .kk-poem-card--image .kk-poet-avatar { display: none; }
}

/* Several pictures: a page-count badge on the card */
.kk-imgpoem-figure { position: relative; }
.kk-imgpoem-pages {
	position: absolute; top: 10px; right: 10px; z-index: 1;
	display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px;
	font: 700 11.5px/1.4 var(--kk-ui); color: #fff; background: rgba(20, 16, 10, .62);
	-webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

/* Reading page (and judging desk): one picture, or a swipeable set */
.kk-imgpoem-single { margin: 22px auto 6px; max-width: 540px; }
.kk-imgpoem-track {
	display: flex; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory;
	scroll-behavior: smooth; overscroll-behavior-x: contain; scrollbar-width: none;
	border-radius: var(--kk-radius); box-shadow: var(--kk-shadow-3); background: var(--kk-surface-2);
}
.kk-imgpoem-track::-webkit-scrollbar { display: none; }
.kk-imgpoem-track:focus-visible { outline: 2px solid var(--kk-green); outline-offset: 3px; }
.kk-imgpoem-track img {
	flex: 0 0 100%; width: 100%; height: auto; aspect-ratio: 4 / 5; object-fit: cover;
	scroll-snap-align: start; scroll-snap-stop: always; display: block;
}
.kk-imgpoem-nav { display: flex; align-items: center; justify-content: center; gap: 12px; margin-top: 10px; }
.kk-imgpoem-arrow,
.kk-imgpoem-pager button {
	width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--kk-line-2);
	background: var(--kk-surface); color: var(--kk-ink); font: 600 22px/1 var(--kk-ui); cursor: pointer;
	display: inline-flex; align-items: center; justify-content: center; padding: 0 0 3px;
	transition: background .15s ease, border-color .15s ease, opacity .15s ease;
}
.kk-imgpoem-arrow:hover:not(:disabled),
.kk-imgpoem-pager button:hover:not(:disabled) { border-color: var(--kk-green); }
.kk-imgpoem-arrow:disabled,
.kk-imgpoem-pager button:disabled { opacity: .35; cursor: default; }
.kk-imgpoem-dots,
.kk-imgpoem-pager-dots { display: inline-flex; gap: 6px; }
.kk-imgpoem-dots i,
.kk-imgpoem-pager-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--kk-line-2); transition: background .2s ease, transform .2s ease; }
.kk-imgpoem-dots i.is-on,
.kk-imgpoem-pager-dots i.is-on { background: var(--kk-green); transform: scale(1.3); }
.kk-imgpoem-count,
.kk-imgpoem-pager-no { font: 600 12.5px var(--kk-ui); color: var(--kk-muted); min-width: 3.2em; text-align: center; }
.kk-imgpoem-single-actions { display: flex; justify-content: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.kk-judge-imgpoem .kk-imgpoem-single { max-width: 340px; margin: 10px 0; }

/* Designer: which picture of a long poem is being previewed */
.kk-imgpoem-pager { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 10px; }
.kk-imgpoem-pager button { width: 34px; height: 34px; font-size: 20px; }
.kk-imgpoem-pagesnote { padding: 7px 10px; border-radius: 8px; background: var(--kk-surface); border: 1px dashed var(--kk-gold-soft); color: var(--kk-ink-2); }
.kk-imgpoem-textnote { text-align: center; font-size: 12.5px; color: var(--kk-muted); margin: 18px 0 0; }
.kk-chip--img { font-weight: 600; }

/* Empty gallery */
.kk-imgpoem-empty { text-align: center; padding: 40px 20px; }
.kk-imgpoem-empty .kk-imgpoem-empty-art { font-size: 44px; }

/* Wide screens with a mouse: the arrows sit on the picture's edges, where the eye already is. */
@media (hover: hover) and (min-width: 700px) {
	.kk-imgpoem-single.is-multi { position: relative; container-type: inline-size; }
	.kk-imgpoem-single.is-multi .kk-imgpoem-arrow {
		position: absolute; top: calc(62.5cqw - 22px); z-index: 1; width: 44px; height: 44px;
		background: rgba(255, 252, 245, .9); border-color: transparent; box-shadow: var(--kk-shadow-2);
	}
	.kk-imgpoem-single.is-multi .kk-imgpoem-arrow[data-dir="-1"] { left: 12px; }
	.kk-imgpoem-single.is-multi .kk-imgpoem-arrow[data-dir="1"] { right: 12px; }
	.kk-imgpoem-single.is-multi .kk-imgpoem-arrow:disabled { opacity: 0; pointer-events: none; }
	.kk-judge-imgpoem .kk-imgpoem-single.is-multi .kk-imgpoem-arrow { width: 36px; height: 36px; top: calc(62.5cqw - 18px); }
}

/* Contest entries are text poems only: the picture option is shut while the contest box is ticked. */
.kk-format-opt.is-locked { cursor: not-allowed; }
.kk-format-opt.is-locked span { opacity: .45; filter: grayscale(1); }
.kk-format-lock { margin: 8px 0 0; padding: 8px 12px; border-radius: 8px; font-size: 13px; line-height: 1.5; background: var(--kk-surface-2); border: 1px dashed var(--kk-gold-soft); color: var(--kk-ink-2); }
.kk-format-lock[hidden] { display: none; }
