/* =========================================================
   R316 Palette Switcher — Front-End Bar
   ========================================================= */

#r316-ps-bar {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 0 32px;
	height: 90px;
	background-color: #ffffff;
	box-shadow: 0 -2px 8px rgba(205, 205, 205, 0.2);
	box-sizing: border-box;
}

/* ── Buttons wrapper ────────────────────────────────── */

.r316-ps-buttons {
	display: flex;
	align-items: center;
	gap: 8px;
}

/* ── Individual palette button ──────────────────────── */

.r316-ps-btn {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 0 16px 0 10px;
	height: 40px;
	border-radius: 100px;
	border: 1px solid var(--global-palette7, #e5e5e5);
	background: #ffffff;
	color: var(--global-palette3, #333);
	font-size: 14px;
	font-weight: 500;
	letter-spacing: 0.02em;
	cursor: pointer;
	transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
	white-space: nowrap;
	font-family: inherit;
	line-height: 1;
}

.r316-ps-btn:hover {
	background: var(--global-palette7, #f5f5f5);
	color: var(--global-palette3, #333);
}

/* Active state — uses palette 7 bg + palette 3 border, no box shadow */
.r316-ps-btn.r316-ps-active {
	background: var(--global-palette7, #f5f5f5);
	border-color: var(--global-palette3, #333);
	color: var(--global-palette3, #333);
}

/* ── 2×2 Color swatch icon ──────────────────────────── */

.r316-ps-swatch {
	display: grid;
	grid-template-columns: 1fr 1fr;
	grid-template-rows: 1fr 1fr;
	width: 18px;
	height: 18px;
	border-radius: 3px;
	overflow: hidden;
	flex-shrink: 0;
	border: 1px solid rgba(0, 0, 0, 0.08);
}

.r316-ps-swatch-cell {
	width: 9px;
	height: 9px;
}

/* ── CTA button group ───────────────────────────────── */

.r316-ps-cta-group {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-left: 4px;
}

/* ── Optional Button 1 — Secondary style ────────────── */
/* Uses Kadence global secondary button CSS vars so it
   automatically updates when the palette is switched.   */

.r316-ps-cta-outline {
	display: inline-flex;
	align-items: center;
	height: 40px;
	padding: 0 20px;
	border-radius: 100px;
	border: 0px none;
	background: var(--global-palette-btn-sec-bg, #f5f5f5);
	color: var(--global-palette-btn-sec, #333);
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
	font-family: inherit;
}

.r316-ps-cta-outline:hover {
	background: var(--global-palette-btn-sec-bg-hover, #e5e5e5);
	color: var(--global-palette-btn-sec-hover, #fff);
	text-decoration: none;
}

/* ── Optional Button 2 — Primary style ─────────────── */
/* Uses Kadence global primary button CSS vars so it
   automatically updates when the palette is switched.   */

.r316-ps-cta-solid {
	display: inline-flex;
	align-items: center;
	height: 40px;
	padding: 0 20px;
	border-radius: 100px;
	border: 0px none;
	background: var(--global-palette-btn-bg, #333);
	color: var(--global-palette-btn, #fff);
	font-size: 14px;
	font-weight: 600;
	letter-spacing: 0.05em;
	text-transform: uppercase;
	text-decoration: none;
	white-space: nowrap;
	cursor: pointer;
	transition: background 0.2s ease, color 0.2s ease;
	font-family: inherit;
}

.r316-ps-cta-solid:hover {
	background: var(--global-palette-btn-bg-hover, #555);
	color: var(--global-palette-btn-hover, #fff);
	text-decoration: none;
}

/* ── Toast notification ─────────────────────────────── */

.r316-ps-toast {
	position: absolute;
	bottom: 76px;
	left: 50%;
	transform: translateX(-50%);
	background: rgba(0, 0, 0, 0.72);
	color: #fff;
	font-size: 13px;
	padding: 6px 16px;
	border-radius: 20px;
	white-space: nowrap;
	pointer-events: none;
	opacity: 0;
	transition: opacity 0.25s ease;
}

.r316-ps-toast.r316-ps-toast--visible {
	opacity: 1;
}

/* Inline shortcode: only palette buttons, wrapping on narrow screens. */
.r316-ps-inline .r316-ps-buttons {
	flex-wrap: wrap;
}

.r316-ps-btn:focus-visible {
	outline: 2px solid var(--global-palette3, #333);
	outline-offset: 3px;
}

/* Three sections keep palettes centered across the viewport. */
#r316-ps-bar {
    height: auto;
    min-height: 90px;
    padding: 16px 24px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}
#r316-ps-bar .r316-ps-buttons,
#r316-ps-bar .r316-ps-cta-group,
.r316-ps-views {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}
.r316-ps-views .r316-ps-btn[aria-pressed="true"] {
    background: #eee;
    border-color: #333;
}
#r316-ps-bar a:focus-visible {
    outline: 2px solid #333;
    outline-offset: 3px;
}
body.r316-ps-active-bar {
    padding-bottom: var(--r316-bar-height, 90px) !important;
}
body.r316-ps-previewing { overflow: hidden; }
.r316-ps-preview {
    position: fixed;
    inset: 0 0 var(--r316-bar-height, 90px);
    z-index: 99998;
    background: #e9e9e9;
    overflow: auto;
    text-align: center;
}
.r316-ps-preview[hidden] { display: none; }
.r316-ps-preview iframe {
    display: block;
    height: 100%;
    max-width: none;
    border: 0;
    margin: 0 auto;
    background: #fff;
}
body.admin-bar .r316-ps-preview { top: 32px; }
@media (max-width: 782px) {
    body.admin-bar .r316-ps-preview { top: 46px; }
}
@media (max-width: 600px) {
    #r316-ps-bar { padding: 10px; gap: 8px; }
    #r316-ps-bar .r316-ps-btn { padding: 0 10px; }
}

/* Compact device controls; accessible names and hover titles retain the labels. */
#r316-ps-bar .r316-ps-device {
    width: 32px;
    height: 32px;
    padding: 0;
    justify-content: center;
    border-radius: 50%;
}
.r316-ps-device svg {
    width: 18px;
    height: 18px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
}

#r316-ps-bar .r316-ps-views {
    grid-column: 1;
    grid-row: 1;
    justify-self: start;
    flex-wrap: nowrap;
}
#r316-ps-bar > .r316-ps-buttons {
    grid-column: 2;
    grid-row: 1;
    justify-self: center;
}
#r316-ps-bar .r316-ps-cta-group {
    grid-column: 3;
    grid-row: 1;
    justify-self: end;
    justify-content: flex-end;
    margin-left: 0;
}
/* Override theme button and text weights, including inline palette switchers. */
#r316-ps-bar .r316-ps-btn,
#r316-ps-bar .r316-ps-btn-label,
#r316-ps-bar .r316-ps-cta-group a,
.r316-ps-inline .r316-ps-btn,
.r316-ps-inline .r316-ps-btn-label {
    font-weight: 600 !important;
}
/* Give longer links room without overlapping the centered palettes. */
@media (max-width: 1400px) {
    #r316-ps-bar { grid-template-columns: auto minmax(0, 1fr); }
    #r316-ps-bar .r316-ps-cta-group { grid-column: 2; }
    #r316-ps-bar > .r316-ps-buttons { grid-column: 1 / -1; grid-row: 2; }
    #r316-ps-bar > .r316-ps-buttons:empty { display: none; }
}
@media (max-width: 480px) {
    #r316-ps-bar { grid-template-columns: minmax(0, 1fr); }
    #r316-ps-bar .r316-ps-views { grid-column: 1; }
    #r316-ps-bar > .r316-ps-buttons { grid-column: 1; grid-row: 2; }
    #r316-ps-bar .r316-ps-cta-group { grid-column: 1; grid-row: 3; }
    #r316-ps-bar .r316-ps-cta-group a { padding: 0 12px; font-size: 12px; }
}
