/**
 * Custom Cookie Consent Pro — Public Stylesheet
 *
 * Styles for front-end, visitor-facing elements: the cookie banner,
 * the preferences modal, and the footer "Cookie Settings" button.
 *
 * Real colors, fonts, and positions become admin-configurable via
 * CSS custom properties in the Banner Customization lesson later in
 * this course. For now we use sensible hardcoded defaults so the
 * banner is fully usable and testable today.
 *
 * @package Custom_Cookie_Consent_Pro
 */

/*
 * We namespace every class with "ccc-" to avoid colliding with the
 * active theme's CSS or other plugins. This is the same principle
 * as our PHP class prefixing, applied to CSS.
 */

/* -------------------------------------------------------------
   Shared box-sizing reset, scoped to our own elements only — we
   never touch box-sizing globally, since that would affect the
   theme and every other plugin's markup too.
------------------------------------------------------------- */
.ccc-banner,
.ccc-modal,
.ccc-footer-settings {
	box-sizing: border-box;
}

.ccc-banner *,
.ccc-modal *,
.ccc-footer-settings * {
	box-sizing: inherit;
}

/* -------------------------------------------------------------
   BANNER
------------------------------------------------------------- */
.ccc-banner {
	position: fixed;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 999999; /* High enough to sit above most theme headers/footers/sliders. */
	background: #1f2937;
	color: #f9fafb;
	padding: 20px;
	box-shadow: 0 -2px 12px rgba( 0, 0, 0, 0.15 );
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-size: 14px;
	line-height: 1.5;
}

/* Hidden state, toggled by JS via this class rather than inline
   styles — keeps all visual rules in CSS where they belong. */
.ccc-banner.ccc-hidden {
	display: none;
}

/* Position variants, selectable from Settings → Cookie Consent →
   General → Banner Position. Default (no modifier) is bottom. */
.ccc-banner--top {
	top: 0;
	bottom: auto;
	box-shadow: 0 2px 12px rgba( 0, 0, 0, 0.15 );
}

.ccc-banner__content {
	max-width: 1200px;
	margin: 0 auto;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
}

.ccc-banner__message {
	margin: 0;
	/* flex: 1 1 400px; */
}

.ccc-banner__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
	flex: 0 0 auto;
}

/* -------------------------------------------------------------
   BUTTONS (shared between banner and modal)
------------------------------------------------------------- */
.ccc-btn {
	cursor: pointer;
	border: 1px solid transparent;
	border-radius: 4px;
	padding: 10px 18px;
	font-size: 14px;
	font-weight: 600;
	font-family: inherit;
	line-height: 1;
	white-space: nowrap;
}

.ccc-btn--primary {
	background: #22c55e;
	color: #0b1120;
}

.ccc-btn--secondary {
	background: transparent;
	color: #f9fafb;
	border-color: #6b7280;
}

.ccc-btn--tertiary {
	background: transparent;
	color: #93c5fd;
	text-decoration: underline;
	border-color: transparent;
}

/* Visible focus outline for keyboard users — required for WCAG
   2.4.7 (Focus Visible). Never remove outline without replacing it. */
.ccc-btn:focus-visible,
.ccc-toggle__input:focus-visible + .ccc-toggle__track,
.ccc-modal__close:focus-visible,
.ccc-footer-settings:focus-visible {
	outline: 2px solid #60a5fa;
	outline-offset: 2px;
}

/* -------------------------------------------------------------
   MODAL
------------------------------------------------------------- */
.ccc-modal {
	position: fixed;
	inset: 0;
	z-index: 1000000; /* Above the banner. */
	display: flex;
	align-items: center;
	justify-content: center;
}

.ccc-modal[aria-hidden='true'] {
	display: none;
}

.ccc-modal__overlay {
	position: absolute;
	inset: 0;
	background: rgba( 0, 0, 0, 0.5 );
}

.ccc-modal__content {
	position: relative;
	background: #ffffff;
	color: #111827;
	width: 100%;
	max-width: 520px;
	max-height: 85vh;
	overflow-y: auto;
	border-radius: 8px;
	padding: 24px;
	font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.ccc-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 16px;
}

.ccc-modal__title {
	margin: 0;
	font-size: 18px;
}

.ccc-modal__close {
	background: transparent;
	border: none;
	cursor: pointer;
	font-size: 22px;
	line-height: 1;
	padding: 4px 8px;
	color: #6b7280;
}

.ccc-modal__body {
	display: flex;
	flex-direction: column;
	gap: 18px;
	margin-bottom: 20px;
}

.ccc-category__header {
	margin-bottom: 4px;
}

.ccc-category__description {
	margin: 0;
	font-size: 13px;
	color: #4b5563;
}

.ccc-modal__footer {
	display: flex;
	justify-content: flex-end;
}

/* -------------------------------------------------------------
   TOGGLE SWITCH
   Built from a real <input type="checkbox"> for native keyboard
   and screen-reader support, visually restyled into a switch.
   The checkbox itself is visually hidden but NOT display:none
   (which would remove it from the accessibility tree) — we use
   a clip technique that keeps it screen-reader-accessible.
------------------------------------------------------------- */
.ccc-toggle {
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	font-weight: 600;
}

.ccc-toggle__input {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect( 0, 0, 0, 0 );
	white-space: nowrap;
	border: 0;
}

.ccc-toggle__track {
	position: relative;
	width: 40px;
	height: 22px;
	background: #d1d5db;
	border-radius: 999px;
	flex-shrink: 0;
	transition: background-color 0.15s ease;
}

.ccc-toggle__track::before {
	content: '';
	position: absolute;
	top: 2px;
	left: 2px;
	width: 18px;
	height: 18px;
	background: #ffffff;
	border-radius: 50%;
	transition: transform 0.15s ease;
}

.ccc-toggle__input:checked + .ccc-toggle__track {
	background: #22c55e;
}

.ccc-toggle__input:checked + .ccc-toggle__track::before {
	transform: translateX( 18px );
}

.ccc-toggle__input:disabled + .ccc-toggle__track {
	background: #86efac;
	opacity: 0.7;
	cursor: not-allowed;
}

/* -------------------------------------------------------------
   FOOTER "COOKIE SETTINGS" BUTTON
------------------------------------------------------------- */
.ccc-footer-settings {
	position: fixed;
	bottom: 16px;
	z-index: 999998; /* Below the banner/modal, always visible otherwise. */
	background: #1f2937;
	color: #f9fafb;
	border: none;
	border-radius: 999px;
	padding: 10px 16px;
	font-size: 12px;
	cursor: pointer;
}

/* Corner is admin-configurable (Settings → Cookie Consent → Footer
   Button Style) specifically so it can be moved away from other
   fixed-position theme elements — chat widgets, floating CTA
   buttons, etc. — that would otherwise collide with it. */
.ccc-footer-settings--bottom-left {
	left: 16px;
}

.ccc-footer-settings--bottom-right {
	right: 16px;
}

.ccc-footer-settings.ccc-hidden {
	display: none;
}

/* "Plain link" style (rendered via the [ccc_cookie_settings]
   shortcode instead of the floating pill) — no fixed positioning
   at all, just a normal inline link the site owner places inside
   their own footer menu/widget markup. */
.ccc-footer-settings-link {
	cursor: pointer;
}

/* -------------------------------------------------------------
   RESPONSIVE
------------------------------------------------------------- */
@media ( max-width: 600px ) {
	.ccc-banner__content {
		flex-direction: column;
		align-items: stretch;
	}

	.ccc-banner__actions {
		justify-content: stretch;
	}

	.ccc-banner__actions .ccc-btn {
		flex: 1 1 auto;
	}
}

/* -------------------------------------------------------------
   MOBILE FLOATING BUTTON SAFE AREA
   On narrow screens, the floating "Cookie Settings" pill is more
   likely to collide with other fixed-position elements the theme
   or page itself adds near a screen corner (floating CTAs, chat
   widgets, "back to top" buttons). Shrinking it to an icon-only
   circle and nudging it up from the very bottom edge reduces the
   chance of overlap; if your theme's own floating button still
   collides, change the "Footer Button Style" setting to "Plain
   link" instead and place the [ccc_cookie_settings] shortcode in
   your footer menu/widget area, or adjust the bottom value below
   to clear your specific theme's floating element.
------------------------------------------------------------- */
@media ( max-width: 480px ) {
	.ccc-footer-settings {
		bottom: 76px;
		padding: 8px 10px;
		font-size: 0;
		width: 36px;
		height: 36px;
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.ccc-footer-settings::before {
		content: '\1F36A'; /* cookie emoji, works with zero extra assets/icon fonts */
		font-size: 16px;
	}
}

/* -------------------------------------------------------------
   DARK MODE
   Respects the visitor's OS-level preference automatically.
   Full admin-configurable dark mode toggle comes in a later
   lesson — this is the baseline that works with zero settings.
------------------------------------------------------------- */
@media ( prefers-color-scheme: dark ) {
	.ccc-modal__content {
		background: #1f2937;
		color: #f9fafb;
	}

	.ccc-category__description {
		color: #9ca3af;
	}

	.ccc-modal__close {
		color: #9ca3af;
	}
}
